Split prod dev and ssl docker-compose files

This commit is contained in:
Hubert Van De Walle 2020-05-03 13:35:45 +02:00
parent 3d17a3e7cb
commit c40a32ca3d
7 changed files with 65 additions and 35 deletions

View File

@ -11,7 +11,7 @@ check_installed docker-compose
check_installed yarn
check_installed mvn
docker-compose down
docker-compose -f docker-compose.yml -f docker-compose.prod.yml down
# Generate Nuxt.js static website
pushd frontend || exit 1
@ -23,4 +23,4 @@ pushd api || exit 1
mvn clean package
popd || exit 1
docker-compose up -d --build
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d --build

7
docker-compose.dev.yml Normal file
View File

@ -0,0 +1,7 @@
version: '2.2'
services:
db:
ports:
- 3306:3306

33
docker-compose.prod.yml Normal file
View File

@ -0,0 +1,33 @@
version: '2.2'
services:
nginx:
image: nginx:latest
container_name: notes-nginx
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/Brussels
volumes:
- ./frontend/dist:/usr/share/nginx/html
- ./nginx:/etc/nginx/conf.d
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
ports:
- 80:80
- 443:443
depends_on:
- api
api:
build: ./api
container_name: notes-api
env_file:
- .env
environment:
- TZ=Europe/Brussels
- MYSQL_HOST=db
depends_on:
db:
condition: service_healthy

9
docker-compose.ssl.yml Normal file
View File

@ -0,0 +1,9 @@
version: '2.2'
services:
certbot:
image: certbot/certbot
volumes:
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot

View File

@ -2,24 +2,6 @@ version: '2.2'
services:
nginx:
image: nginx:latest
container_name: notes-nginx
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/Brussels
volumes:
- ./frontend/dist:/usr/share/nginx/html
- ./nginx:/etc/nginx/conf.d
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
ports:
- 80:80
- 443:443
depends_on:
- api
db:
image: mariadb
container_name: notes-mariadb
@ -36,18 +18,5 @@ services:
timeout: 10s
retries: 10
api:
build: ./api
container_name: notes-api
env_file:
- .env
environment:
- TZ=Europe/Brussels
- MYSQL_HOST=db
depends_on:
db:
condition: service_healthy
volumes:
notes-db-volume:

View File

@ -10,11 +10,11 @@ check_installed() {
check_installed docker-compose
check_installed yarn
docker-compose stop nginx
docker-compose -f docker-compose.yml -f docker-compose.prod.yml stop nginx
# Generate Nuxt.js static website
pushd frontend || exit 1
yarn run generate
popd || exit 1
docker-compose up -d --build nginx
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d --build nginx

12
start-db-dev.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
check_installed() {
if ! [ -x "$(command -v $1)" ]; then
echo "Error: $1 is not installed." >&2
exit 1
fi
}
check_installed docker-compose
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d --build