Author: acheype Date: 2017-08-10 10:05:10 +0200 (Thu, 10 Aug 2017) New Revision: 280 Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/280 Log: Divide the docker directory in two : dev and prod + adapt the README.md Added: trunk/docker/dev/ trunk/docker/dev/cantharella-web/ trunk/docker/prod/ trunk/docker/prod/docker-compose.yml Removed: trunk/docker/cantharella-web/ trunk/docker/docker-compose-prod.yml trunk/docker/docker-compose.yml Modified: trunk/README.md Modified: trunk/README.md =================================================================== --- trunk/README.md 2017-08-09 07:34:34 UTC (rev 279) +++ trunk/README.md 2017-08-10 08:05:10 UTC (rev 280) @@ -11,7 +11,7 @@ Cantharella is an open source information system based on Java components and a PostgreSQL database. -***News from 2017-08:***The application have been dockerized. See [Deployment with Docker](#deployment-with-docker) +**News from 2017-08:**The application have been dockerized. See [Deployment with Docker](#deployment-with-docker) section. More info on the project, [here](src/site/rst/index.rst). @@ -69,27 +69,27 @@ #### Building -First construct the war from the project sources with mvn (from the project root) +First, from the project root, construct the war from the project sources with mvn : mvn clean package -Then copy this war and the sql scripts (if needed, replace the version number) +Then copy this war and the sql scripts (if needed, replace the version number) : - cp cantharella.web/target/cantharella-1.2.2.war docker/cantharella-web/cantharella.war - cp -R sql docker/cantharella-db/docker-entrypoint-initdb.d + cp cantharella.web/target/cantharella-1.2.2.war docker/dev/cantharella-web/cantharella.war + cp -R sql docker/dev/cantharella-db/docker-entrypoint-initdb.d -Then build the images (cantharella.db and cantharella.web) +Then build the project images (`cantharella-db` and `cantharella-web` at the same time) - cd docker + cd docker/dev docker-compose build #### Starting the application -Go into the docker directory and launch the application with the docker-compose command : +Go into the `docker/dev` directory and launch the application with the docker-compose command : docker-compose up -Then, you can verify the status of the two containers (cantharella.db and cantharella.web) : +Then, you can verify the status of the two containers (`cantharella-db` and `cantharella-web`) : docker ps @@ -99,14 +99,14 @@ ### In production environment -### Starting the application +#### Starting the application -In the production environment, the compose configuration file is the `docker-compose-prod.yml` in the docker directory. +In the production environment, the compose configuration file is in the `docker/prod` directory. -Only this file is needed to start the application, the two containers (cantharella.db and cantharella.web) are -created from version-tagged image downloaded from the Docker Hub. +Only this file is needed to start the application, the two containers, `cantharella.db` and `cantharella.web`, are +created from the version-tagged image downloaded from the Docker Hub. -First next to the `docker-compose-prod.yml`, create two config files necessary to define your passwords. The first one +First next to the `docker-compose-prod.yml`, create two config files needed to define your passwords. The first one `cantharella-db.env` must have this content : POSTGRES_PASSWORD=thePasswordForTheAdminCountOfTheDB @@ -117,14 +117,29 @@ DB.PASSWORD=thePasswordOfTheCantharellaUserUsedConnectingTheWebAppToTheDB In the latter, you can also define other variables of the web application configuration file (see the documentation -file /src/site/rst/configuration.rst for more details). +file `/src/site/rst/configuration.rst` for more details). When the configuration file are set, you can launch the application with the docker-compose command : - docker-compose -f docker-compose-prod.yml + docker-compose up -### Autostart using Systemd +As with the dev environment, you can verify the status of the containers with `docker ps` and stop properly the +application with `docker-compose down`. +The database data will be stored in the directory `/data/postgres`. If this location refer to an existing postgres +data directory, the application expects that a cantharella database already exists. However, the container will +create a new postgres directory and init an empty cantharella database. + +If needed, it's possible to modify the postgres data directory location by changing in the `docker-compose.yml` the +part before `:` in that section : + +``` +volumes: + - /data/postgresql:/var/lib/postgresql/data +``` + +#### Autostart using Systemd + For linux system which rely on systemd, the followed configuration will automatically execute a Cantharella service at system startup. @@ -145,7 +160,7 @@ [Install] WantedBy=multi-user.target ``` -(adapt the path for the docker-compose.yml according to your situation) +(adapt the path for the `docker-compose.yml` according to your situation) Then enable the start at startup : Deleted: trunk/docker/docker-compose-prod.yml =================================================================== --- trunk/docker/docker-compose-prod.yml 2017-08-09 07:34:34 UTC (rev 279) +++ trunk/docker/docker-compose-prod.yml 2017-08-10 08:05:10 UTC (rev 280) @@ -1,28 +0,0 @@ -version: '3' -services: - tomcat: - container_name: cantharella-web - image: acheype/cantharella-web:1.2.2 - ports: - - "80:8080" - links: - - "postgres" - env_file: ./cantharella-web.env - # please define the variable DB.PASSWORD in the cantharella-db.env file. You can also define other variables - # of the configuration file (see the documentation file /src/site/rst/configuration.rst for more details) - # example of the environment file content : - # DB.PASSWORD=ctrl4 - - postgres: - container_name: cantharella-db - image: acheype/cantharella-db:1.2 - volumes: - - /data/postgresql:/var/lib/postgresql/data - ports: - - "5432:5432" - env_file: ./cantharella-db.env - # please define the variables POSTGRES_PASSWORD and CANTHARELLA_PASSWORD (same value as DB.PASSWORD) in the - # cantharella-db .env file - # example of the environment file content : - # POSTGRES_PASSWORD=postgres - # CANTHARELLA_PASSWORD=ctrl4 \ No newline at end of file Deleted: trunk/docker/docker-compose.yml =================================================================== --- trunk/docker/docker-compose.yml 2017-08-09 07:34:34 UTC (rev 279) +++ trunk/docker/docker-compose.yml 2017-08-10 08:05:10 UTC (rev 280) @@ -1,23 +0,0 @@ -version: '3' -services: - tomcat: - container_name: cantharella-web - build: ./cantharella-web - image: acheype/cantharella-web - ports: - - "80:8080" - links: - - "postgres" - - postgres: - container_name: cantharella-db - build: ./cantharella-db - image: acheype/cantharella-db - volumes: - - /data/postgresql:/var/lib/postgresql/data - ports: - - "5432:5432" - environment: - - POSTGRES_PASSWORD=postgres - # password of the user cantharella, only useful for db creation (if no data in /data/postgresql) - - CANTHARELLA_PASSWORD=ctrl4 \ No newline at end of file Copied: trunk/docker/prod/docker-compose.yml (from rev 279, trunk/docker/docker-compose-prod.yml) =================================================================== --- trunk/docker/prod/docker-compose.yml (rev 0) +++ trunk/docker/prod/docker-compose.yml 2017-08-10 08:05:10 UTC (rev 280) @@ -0,0 +1,28 @@ +version: '3' +services: + tomcat: + container_name: cantharella-web + image: acheype/cantharella-web:1.2.2 + ports: + - "80:8080" + links: + - "postgres" + env_file: ./cantharella-web.env + # please define the variable DB.PASSWORD in the cantharella-db.env file. You can also define other variables + # of the configuration file (see the documentation file /src/site/rst/configuration.rst for more details) + # example of the environment file content : + # DB.PASSWORD=ctrl4 + + postgres: + container_name: cantharella-db + image: acheype/cantharella-db:1.2 + volumes: + - /data/postgresql:/var/lib/postgresql/data + ports: + - "5432:5432" + env_file: ./cantharella-db.env + # please define the variables POSTGRES_PASSWORD and CANTHARELLA_PASSWORD (same value as DB.PASSWORD) in the + # cantharella-db .env file + # example of the environment file content : + # POSTGRES_PASSWORD=postgres + # CANTHARELLA_PASSWORD=ctrl4 \ No newline at end of file