diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 23d6c64..7f0623f 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -55,6 +55,6 @@ jobs: - name: Deploy run: | cd $HOME/mally && - docker compose -f docker-compose.prod.yml down && - docker compose -f docker-compose.prod.yml pull && - docker compose -f docker-compose.prod.yml up -d + docker compose -f docker-compose.stack.yml pull && + export $(cat .env) && + docker stack deploy -c docker-compose.stack.yml mally diff --git a/apps/api/src/main/resources/application.prod.yml b/apps/api/src/main/resources/application.prod.yml index 103bf0e..a586b57 100644 --- a/apps/api/src/main/resources/application.prod.yml +++ b/apps/api/src/main/resources/application.prod.yml @@ -3,6 +3,7 @@ spring: url: jdbc:${DATABASE_URL} username: ${DATABASE_USERNAME} password: ${DATABASE_PASSWORD} + driverClassName: org.postgresql.Driver jpa: database-platform: org.hibernate.dialect.PostgreSQLDialect diff --git a/apps/api/src/main/resources/application.testing.yml b/apps/api/src/main/resources/application.testing.yml index 0398193..1c3541e 100644 --- a/apps/api/src/main/resources/application.testing.yml +++ b/apps/api/src/main/resources/application.testing.yml @@ -3,6 +3,7 @@ spring: url: jdbc:postgresql://postgres:5432/mally username: postgres password: postgres + driverClassName: org.postgresql.Driver jpa: database-platform: org.hibernate.dialect.PostgreSQLDialect diff --git a/apps/api/src/main/resources/application.yml b/apps/api/src/main/resources/application.yml index 2b29ae7..30be925 100644 --- a/apps/api/src/main/resources/application.yml +++ b/apps/api/src/main/resources/application.yml @@ -3,6 +3,7 @@ spring: url: jdbc:postgresql://localhost:5432/mally username: postgres password: postgres + driverClassName: org.postgresql.Driver jpa: database-platform: org.hibernate.dialect.PostgreSQLDialect diff --git a/docker-compose.prod.yml b/docker-compose.stack.yml similarity index 63% rename from docker-compose.prod.yml rename to docker-compose.stack.yml index 1bfb8ac..5aac439 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.stack.yml @@ -1,10 +1,10 @@ +version: '3.7' + services: postgres: - container_name: mally-postgres image: ghcr.io/neumanf/mally-postgres - restart: unless-stopped healthcheck: - test: [ "CMD", "pg_isready", "-q", "-d", "keycloak", "-U", "postgres" ] + test: pg_isready -q -d keycloak -U postgres timeout: 45s interval: 10s retries: 5 @@ -20,11 +20,9 @@ services: - postgres:/var/lib/postgresql/data keycloak: - container_name: mally-keycloak image: ghcr.io/neumanf/mally-keycloak - restart: unless-stopped healthcheck: - test: ["CMD", "curl", "-f", "http://0.0.0.0:9000/health/ready"] + test: curl -f http://localhost:9000/health/ready timeout: 45s interval: 10s retries: 15 @@ -45,19 +43,14 @@ services: KEYCLOAK_ADMIN_PASSWORD: ${KEYCLOAK_ADMIN_PASSWORD} env_file: - .env - depends_on: - postgres: - condition: service_healthy networks: - mally-network command: start --hostname ${KEYCLOAK_URL} --import-realm api: - container_name: mally-api image: ghcr.io/neumanf/mally-api - restart: unless-stopped healthcheck: - test: [ "CMD", "curl", "-f", "http://0.0.0.0:8080/health/" ] + test: curl -f http://localhost:8080/health/ timeout: 45s interval: 10s retries: 15 @@ -73,52 +66,76 @@ services: - ./logs/api:/app/logs/api networks: - mally-network - depends_on: - postgres: - condition: service_healthy - keycloak: - condition: service_healthy + deploy: + mode: replicated + replicas: 2 + update_config: + order: start-first + failure_action: rollback + delay: 5s + placement: + constraints: + - node.role == manager ui: - container_name: mally-ui image: ghcr.io/neumanf/mally-ui - restart: unless-stopped + healthcheck: + test: curl -f http://localhost || exit 1 + timeout: 45s + interval: 10s + retries: 15 networks: - mally-network - depends_on: - api: - condition: service_healthy - keycloak: - condition: service_healthy + deploy: + mode: replicated + replicas: 2 + update_config: + order: start-first + failure_action: rollback + delay: 5s nginx: - container_name: mally-nginx image: ghcr.io/neumanf/mally-nginx - restart: unless-stopped + healthcheck: + test: curl -f http://localhost || exit 1 + timeout: 45s + interval: 10s + retries: 15 networks: - mally-network - depends_on: - - api - - ui ports: - '80:80' - '443:443' volumes: - ./certbot/www/:/var/www/certbot/:rw - ./certbot/conf/:/etc/letsencrypt/:rw + deploy: + restart_policy: + condition: on-failure + delay: 10s + max_attempts: 15 + placement: + constraints: + - node.role == manager loki: - container_name: mally-loki image: ghcr.io/neumanf/mally-loki - restart: unless-stopped + healthcheck: + test: wget --no-verbose --tries=1 --spider http://localhost:3100/ready || exit 1 + timeout: 45s + interval: 10s + retries: 15 command: -config.file=/etc/loki/loki.yml networks: - mally-network promtail: - container_name: mally-promtail image: ghcr.io/neumanf/mally-promtail - restart: unless-stopped + healthcheck: + test: wget --no-verbose --tries=1 --spider http://localhost:9080/ready || exit 1 + timeout: 45s + interval: 10s + retries: 15 volumes: - ./logs/api/:/var/log/ command: -config.file=/etc/promtail/promtail.yml @@ -126,17 +143,23 @@ services: - mally-network prometheus: - container_name: mally-prometheus image: ghcr.io/neumanf/mally-prometheus - restart: unless-stopped + healthcheck: + test: wget --no-verbose --tries=1 --spider http://localhost:9090 || exit 1 + timeout: 45s + interval: 10s + retries: 15 command: '--config.file=/etc/prometheus/config.yml' networks: - mally-network grafana: - container_name: mally-grafana image: ghcr.io/neumanf/mally-grafana - restart: unless-stopped + healthcheck: + test: curl -f http://localhost:3000/ + timeout: 45s + interval: 10s + retries: 15 environment: GF_SECURITY_ADMIN_USER: ${GRAFANA_USER} GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD}