From 062a677ce1d04454a9b2158046cda82793c6d112 Mon Sep 17 00:00:00 2001 From: GustavH Date: Sun, 20 Oct 2024 19:41:52 +0200 Subject: [PATCH 1/3] prod docker compose --- docker-compose.prod.yml | 84 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 docker-compose.prod.yml diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 0000000..62d7076 --- /dev/null +++ b/docker-compose.prod.yml @@ -0,0 +1,84 @@ +services: + watchtower: + image: containrrr/watchtower + command: + - "--label-enable" + - "--interval" + - "30" + - "--rolling-restart" + volumes: + - /var/run/docker.sock:/var/run/docker.sock + reverse-proxy: + image: traefik:v3.1 + command: + - "--providers.docker" + - "--providers.docker.exposedbydefault=false" + - "--entryPoints.websecure.address=:443" + - "--certificatesresolvers.myresolver.acme.tlschallenge=true" + - "--certificatesresolvers.myresolver.acme.email=commercify@zenfulcode.com" + - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json" + - "--entrypoints.web.address=:80" + - "--entrypoints.web.http.redirections.entrypoint.to=websecure" + - "--entrypoints.web.http.redirections.entrypoint.scheme=https" + ports: + - "80:80" + - "443:443" + volumes: + - letsencrypt:/letsencrypt + - /var/run/docker.sock:/var/run/docker.sock + mysql-db: + image: docker.io/bitnami/mysql:8.4 + container_name: mysql-db + env_file: .env + environment: + ALLOW_EMPTY_PASSWORD: "no" + MYSQL_DATABASE: commercifydb + MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} + MYSQL_USER: ${MYSQL_USER} + MYSQL_PASSWORD: ${MYSQL_PASSWORD} + ports: + - "3306:3306" + networks: + - spring-net + volumes: + - mysql-data:/bitnami/mysql/data + # - ./mysql-init-scripts:/docker-entrypoint-initdb.d + healthcheck: + test: ["CMD", "/opt/bitnami/scripts/mysql/healthcheck.sh"] + interval: 15s + timeout: 5s + retries: 6 + + commercify: + image: ghcr.io/zenfulcode/commercify:main + env_file: .env + container_name: commercify-api + labels: + - "traefik.enable=true" + - "traefik.http.routers.commercify.rule=Host(`zenfulcode.com`)" + - "traefik.http.routers.commercify.entrypoints=websecure" + - "traefik.http.routers.commercify.tls.certresolver=myresolver" + - "com.centurylinklabs.watchtower.enable=true" + ports: + - "8080:8080" + environment: + - SPRING_PROFILES_ACTIVE=docker + - SPRING_DATASOURCE_URL=${SPRING_DATASOURCE_URL} + - SPRING_DATASOURCE_USERNAME=${SPRING_DATASOURCE_USERNAME} + - SPRING_DATASOURCE_PASSWORD=${SPRING_DATASOURCE_PASSWORD} + - STRIPE_TEST_SECRET=${STRIPE_TEST_SECRET} + - JWT_SECRET_KEY=${JWT_SECRET_KEY} + depends_on: + mysql-db: + condition: service_healthy + networks: + - spring-net + +networks: + spring-net: + driver: bridge + +volumes: + letsencrypt: + mysql-data: + driver: local From 549018d77d4f538ae750fdec846443840cf5c78e Mon Sep 17 00:00:00 2001 From: GustavH Date: Sun, 20 Oct 2024 19:43:10 +0200 Subject: [PATCH 2/3] Refactor docker-compose.prod.yml to remove unused network configurations --- docker-compose.prod.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 62d7076..6952ed5 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -38,8 +38,6 @@ services: MYSQL_PASSWORD: ${MYSQL_PASSWORD} ports: - "3306:3306" - networks: - - spring-net volumes: - mysql-data:/bitnami/mysql/data # - ./mysql-init-scripts:/docker-entrypoint-initdb.d @@ -71,12 +69,6 @@ services: depends_on: mysql-db: condition: service_healthy - networks: - - spring-net - -networks: - spring-net: - driver: bridge volumes: letsencrypt: From b2d87ab0fe644059325f2434653a3670409adb54 Mon Sep 17 00:00:00 2001 From: GustavH Date: Sun, 20 Oct 2024 22:28:29 +0200 Subject: [PATCH 3/3] Refactor docker-compose.prod.yml to expose ports and update URLs --- docker-compose.prod.yml | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 6952ed5..9ea94c5 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -22,6 +22,7 @@ services: - "--entrypoints.web.http.redirections.entrypoint.scheme=https" ports: - "80:80" + - "8080:8080" - "443:443" volumes: - letsencrypt:/letsencrypt @@ -36,8 +37,8 @@ services: MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} MYSQL_USER: ${MYSQL_USER} MYSQL_PASSWORD: ${MYSQL_PASSWORD} - ports: - - "3306:3306" + expose: + - 3306 volumes: - mysql-data:/bitnami/mysql/data # - ./mysql-init-scripts:/docker-entrypoint-initdb.d @@ -47,18 +48,32 @@ services: timeout: 5s retries: 6 - commercify: - image: ghcr.io/zenfulcode/commercify:main + commercifyweb: + image: ghcr.io/zenfulcode/commercifyweb:dev env_file: .env - container_name: commercify-api labels: - "traefik.enable=true" - - "traefik.http.routers.commercify.rule=Host(`zenfulcode.com`)" + - "traefik.http.routers.commercify.rule=Host(`commercify.app`)" - "traefik.http.routers.commercify.entrypoints=websecure" - "traefik.http.routers.commercify.tls.certresolver=myresolver" - "com.centurylinklabs.watchtower.enable=true" - ports: - - "8080:8080" + environment: + - NEXT_PUBLIC_COMMERCIFY_API_URL=https://commercify.app:6091/api/v1 + # deploy: + # mode: replicated + # replicas: 3 + depends_on: + - commercify + + commercify: + image: ghcr.io/zenfulcode/commercify:dev + env_file: .env + labels: + - "traefik.enable=true" + - "traefik.http.routers.commercify-api.rule=Host(`api.commercify.app`)" + - "traefik.http.routers.commercify-api.entrypoints=websecure" + - "traefik.http.routers.commercify-api.tls.certresolver=myresolver" + - "com.centurylinklabs.watchtower.enable=true" environment: - SPRING_PROFILES_ACTIVE=docker - SPRING_DATASOURCE_URL=${SPRING_DATASOURCE_URL} @@ -66,6 +81,11 @@ services: - SPRING_DATASOURCE_PASSWORD=${SPRING_DATASOURCE_PASSWORD} - STRIPE_TEST_SECRET=${STRIPE_TEST_SECRET} - JWT_SECRET_KEY=${JWT_SECRET_KEY} + expose: + - 6091 + # deploy: + # mode: replicated + # replicas: 3 depends_on: mysql-db: condition: service_healthy