From 674630ee95fba635998c88bc4b652e765a8de936 Mon Sep 17 00:00:00 2001 From: Bodo Hugo Barwich Date: Sun, 22 Aug 2021 13:10:44 +0100 Subject: [PATCH 1/5] PostgreSQL Database Container Image --- Dockerfile | 2 +- data/.keep | 0 docker-compose.yml.example | 12 ++++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 data/.keep diff --git a/Dockerfile b/Dockerfile index fac0779..f53335e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ RUN apt-get update &&\ libsyntax-keyword-try-perl libcapture-tiny-perl libhttp-tinyish-perl libnet-ssleay-perl\ liburl-encode-perl libextutils-config-perl libextutils-helpers-perl libextutils-installpaths-perl\ libclone-choose-perl libhash-merge-perl libtest-deep-perl liburi-nested-perl\ - libsql-abstract-perl liburi-db-perl libdbd-sqlite3-perl + libsql-abstract-perl liburi-db-perl libdbd-sqlite3-perl postgresql-server-dev-all RUN mkdir -p /usr/share/perldoc-browser/log COPY cpanfile cpanfile-cpandoc /usr/share/perldoc-browser/ RUN cd /usr/share/perldoc-browser/\ diff --git a/data/.keep b/data/.keep new file mode 100644 index 0000000..e69de29 diff --git a/docker-compose.yml.example b/docker-compose.yml.example index e871fa0..54058b3 100644 --- a/docker-compose.yml.example +++ b/docker-compose.yml.example @@ -1,5 +1,17 @@ version: '3' services: + db: + container_name: 'perldoc_db' + image: postgres:11.13-alpine3.14 +# restart: always + ports: + - "5432:5432" + volumes: + - /absolute/path/to/project/data:/var/lib/postgresql/data:Z + environment: + - COMPONENT=perldoc_db + - POSTGRES_USER=perldoc + - POSTGRES_PASSWORD=secret web: container_name: 'perldoc_web' image: perldoc_web From 24fc411cf755e9c67adc6b7d3fc1fcda9f2f536a Mon Sep 17 00:00:00 2001 From: Bodo Hugo Barwich Date: Sun, 22 Aug 2021 13:45:21 +0100 Subject: [PATCH 2/5] exclude database storage --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 377c213..f595ce9 100644 --- a/.gitignore +++ b/.gitignore @@ -17,5 +17,10 @@ hypnotoad.pid perl5 perl5/* +#Database Container Storage +data +data/* +~data/.keep + #Local Docker-Compose Configuration docker-compose.yml From dc32468946779c67936386e23578c2007186a454 Mon Sep 17 00:00:00 2001 From: Bodo Hugo Barwich Date: Sun, 22 Aug 2021 19:25:20 +0100 Subject: [PATCH 3/5] instructions for postgres build --- etc/docker/README.pod | 103 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 85 insertions(+), 18 deletions(-) diff --git a/etc/docker/README.pod b/etc/docker/README.pod index 909798c..74704db 100644 --- a/etc/docker/README.pod +++ b/etc/docker/README.pod @@ -44,6 +44,8 @@ L =item * The Docker Service must be running =item * Build User must have access to the Docker Service (perhaps C access is required) + the Build User Account must be part of the C User Group as described at +L =item * Current Working Directory must be the Project Root Directory @@ -52,28 +54,40 @@ L =back -=item Build with Docker - -The Container Image for the C Web Service was called "I" to difference it -from the Backend Container Image. -So the command to build the docker image is: - - docker build -t perldoc_web . - =item Build with C -To build the Container Image with C a F file is required. +To build the Container Images with C a F file is required. It can be created from the F file by copying it. -Within the F file the entry C must be configured to -contain the absolute path to the Project Root Directory on the system. +The F file describes two Services, C and C, which are the +C Web Application as C and the C Database as C. +Within the F file the entries C and C +must be configured to contain the absolute path to the Project Root Directory on the system. The F file contains instructions to expose the C Web Service on Port C<3000> which seems to be the default behaviour for the Application. If the Application was configured to listen on a different port the file entry C must be adjusted accordingly. -So the command to build the docker image and launch it is: +It also exposes the C Database on Port C<5432>. +So the command to build the docker images and launch them is: docker-compose up --build +To build only the Web Service image it can be done by naming it explicitly like: + + docker-compose up --build web + +=item Build with Docker + +The Container Image for the C Web Service was called "I" to difference it +from the C Database Backend Container Image which is called "I". +So the commands to build the docker image is: + + docker build -t perldoc_web . + +The C Database Image does not need to be built. It will only be downloaded +as it is from the C. Therefore it does not have a F file. +Any Download and initial configuration of the Database Image will happen at Start-Up +with the C command. + =back =head1 IMAGE INITIALISATION @@ -85,7 +99,7 @@ So the command to build the docker image and launch it is: As discussed in the task issue L the installation of the I Modules for the SQLite Backend from the F was executed at Image Build Time. So on updates of the F it is recommendable to rebuild the Container Image as described above -under B. +under L>. The used F can be found in F within the Docker Image. Also the C Installation Log is found inside the Image in F. @@ -96,21 +110,74 @@ To inspect the Docker Image run the command: This will give a C shell and the file system can be inspected. -Still the Start-Up Script will detect a different backend configuration or the -C Command and check whether key dependencies are met and run the -C Installation accordingly +Still the Container Start-Up Script F will detect a different backend configuration +or the C Command and check whether the key dependencies are met +and run the C Installation accordingly + +=item starting up the Docker Cluster + +The C Database is only within the C environment known with the hostname C. +So to use the database hostname C any command must be run within the C environment. +To startup the Docker Cluster with the C environment the following command +is needed at first: + + docker-compose up -d + +It is important to verify that the containers are running correctly with: +(The Container State must be in C) + + docker-compose ps =item populating the search backend The new built Container Image contains an empty C Installation To run correctly the Search Backend needs to be populated. -So the command to populate the Search Backend is: - docker run -it -v /absolute/path/to/project:/home/perldoc-browser:Z perldoc_web perldoc-browser.pl index all +Now the command to populate the Search Backend is: + + docker-compose exec web entrypoint.sh perldoc-browser.pl index all This will execute command C in the project directory. The results will be stored persistently in the project directory for further container launches. +=item accessing the C Database + +To be able to access the database the Docker Cluster must be launched as described +in L>. + +Next the command C can be used within the C container. +The C image is based on I +So a console access can be obtained with the C command: + + docker-compose exec db /bin/sh + +The default database is called "I" and the database login is also called "I". +So to login into the database the C command is: + + psql -h db -U perldoc perldoc + +With an initialized database the "I" database should contain 6 tables: + + perldoc=# \dt + List of relations + Schema | Name | Type | Owner + --------+-----------------+-------+--------- + public | faqs | table | perldoc + public | functions | table | perldoc + public | mojo_migrations | table | perldoc + public | perldeltas | table | perldoc + public | pods | table | perldoc + public | variables | table | perldoc + (6 rows) + +The C table can contain for 1 I Version 1456 entries: + + perldoc=# select count(*) from pods; + count + ------- + 1456 + (1 row) + =back =cut From c448969aa696582127738a81dd839b37e3cbc717 Mon Sep 17 00:00:00 2001 From: Bodo Hugo Barwich Date: Sun, 22 Aug 2021 19:58:47 +0100 Subject: [PATCH 4/5] correct except instruction for data directory --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f595ce9..1c237bf 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,7 @@ perl5/* #Database Container Storage data data/* -~data/.keep +!data/.keep #Local Docker-Compose Configuration docker-compose.yml From 4cd9ba1f3003e2020504a30fc86a55d6e60894e4 Mon Sep 17 00:00:00 2001 From: Bodo Hugo Barwich Date: Sun, 5 Sep 2021 17:07:26 +0100 Subject: [PATCH 5/5] exclude database storage from build context --- .dockerignore | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..45366e1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +#exclude git from the build context +.git + +#exclude the database storage directory +data