Skip to content

Commit

Permalink
feat: docker compose updates (#520)
Browse files Browse the repository at this point in the history
* Compose v3.9

* DC extensions for shared vars

* mvnx +w

* Cleanup and simplification

* Cleanup and simplification

* Restore logging as a default

* Compose reference link

* Fix frontend entrypoint

* Restore finer grained health checks

* Cleanup

* Simplify - replace working_dir with cd

* Fix backend

* Volume for node_modules
  • Loading branch information
DerekRoberts authored Jul 19, 2023
1 parent db68f2e commit 6858ef2
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 60 deletions.
Empty file modified backend/mvnw
100644 → 100755
Empty file.
110 changes: 50 additions & 60 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,72 @@
version: "3.8"
# Compose v3 ref: https://docs.docker.com/compose/compose-file/compose-file-v3/
---
version: "3.9"

x-var:
- &POSTGRES_USER
postgres
- &POSTGRES_PASSWORD
default
- &POSTGRES_DATABASE
postgres
- &POSTGRES_HOST
database

x-defaults: &defaults
logging:
driver: "json-file"
options:
max-size: 10m
max-file: "3"

services:
database:
container_name: postgres
container_name: *POSTGRES_HOST
environment:
POSTGRES_USER: default
POSTGRES_PASSWORD: default
POSTGRES_DB: default
hostname: database
POSTGRES_USER: *POSTGRES_USER
POSTGRES_PASSWORD: *POSTGRES_PASSWORD
POSTGRES_DB: *POSTGRES_DATABASE
image: postgres:15
ports:
- "5432:5432"
restart: always
volumes:
- ./database/init-db.sh:/docker-entrypoint-initdb.d/init-db.sh
- /pgdata
ports: [5432:5432]
volumes: ["/pgdata"]
healthcheck:
test: [ "CMD-SHELL", "pg_isready", "-d", "db_prod" ]
test: ["CMD", "pg_isready", "-U", *POSTGRES_USER]
interval: 5s
timeout: 10s
retries: 10
logging:
driver: "json-file"
options:
max-size: 10m
max-file: "3"
<<: *defaults

backend:
container_name: backend
image: maven:3.9.3-eclipse-temurin-17
entrypoint: sh -c "cd /app && mvn -ntp spring-boot:run -Dspring-boot.run.jvmArguments='-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n'"
environment:
POSTGRESQL_HOST: database
POSTGRESQL_USER: default
POSTGRESQL_PASSWORD: default
POSTGRESQL_DATABASE: default
POSTGRESQL_HOST: *POSTGRES_HOST
POSTGRESQL_USER: *POSTGRES_USER
POSTGRESQL_PASSWORD: *POSTGRES_PASSWORD
POSTGRESQL_DATABASE: *POSTGRES_DATABASE
CHES_CLIENT_ID: id
CHES_CLIENT_SECRET: secret
CHES_TOKEN_URL: https://dev.loginproxy.gov.bc.ca/auth/realms/comsvcauth/protocol/openid-connect/token
CHES_API_URL: https://ches-dev.api.gov.bc.ca/api/v1
ports:
- 3000:3000
ENV LANG: en_CA.UTF-8
LANGUAGE: en_CA.UTF-8
LC_ALL: en_CA.UTF-8
ports: [3000:3000]
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 1m30s
timeout: 10s
retries: 3
start_period: 10s
hostname: backend
image: ghcr.io/bcgov/nr-forest-client/backend:517
depends_on:
- database
links:
- database
logging:
driver: "json-file"
options:
max-size: 10m
max-file: "3"
depends_on: [*POSTGRES_HOST]
volumes: ["./backend:/app"]
<<: *defaults

frontend:
container_name: frontend
image: node:18-bullseye
entrypoint: sh -c "cd /app && npm i && npm start"
environment:
NODE_ENV: development
VITE_BACKEND_URL: backend
Expand All @@ -68,42 +76,24 @@ services:
timeout: 10s
retries: 3
start_period: 40s
hostname: frontend
image: ghcr.io/bcgov/nr-forest-client/frontend:500
links:
- backend
ports:
- "8080:8080"
logging:
driver: "json-file"
options:
max-size: 10m
max-file: "3"
depends_on: [backend]
ports: [8080:8080]
volumes: ["./frontend:/app", "/app/node_modules"]
<<: *defaults

legacydb:
container_name: oracle
environment:
APP_USER_PASSWORD: default
APP_USER: THE
ORACLE_RANDOM_PASSWORD: yes
hostname: legacydb
platform: "linux/amd64"
image: gvenzl/oracle-xe:21.3.0-slim-faststart
ports:
- 1521:1521
restart: always
volumes:
- oracle:/opt/oracle/oradata gvenzl/oracle-xe
ports: [1521:1521]
volumes: [/opt/oracle/oradata gvenzl/oracle-xe]
healthcheck:
test: [ "CMD-SHELL", "healthcheck.sh" ]
interval: 5s
timeout: 10s
retries: 10
logging:
driver: "json-file"
options:
max-size: 10m
max-file: "3"

volumes:
oracle: {}
<<: *defaults

0 comments on commit 6858ef2

Please sign in to comment.