diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 2e90476ba..edc1ff098 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -119,7 +119,7 @@ jobs: docker compose -f ${{ env.DOCKER_STACK_PATH }} config - > ${{ env.STACK_FILE }} + > ${{ env.STACK_FILE }} && docker compose config | sed '/^name:*/d' > /target - name: Move Stack File to Server uses: appleboy/scp-action@v0.1.1 @@ -234,4 +234,4 @@ jobs: username: ${{ secrets.PROD_SERVER_USER }} key: ${{ secrets.PROD_SSH_PRIVATE_KEY }} port: ${{ secrets.PROD_SERVER_PORT }} - script: docker stack deploy --prune --resolve-image=always --with-registry-auth -c /tmp/${{ env.STACK_FILE }} ${{ env.PRODUCTION_STACK_NAME }} \ No newline at end of file + script: docker stack deploy --prune --resolve-image=changed --with-registry-auth -c /tmp/${{ env.STACK_FILE }} ${{ env.PRODUCTION_STACK_NAME }} \ No newline at end of file diff --git a/docker-compose.production.yml b/docker-compose.production.yml index c880dc8d4..487d43878 100644 --- a/docker-compose.production.yml +++ b/docker-compose.production.yml @@ -1,81 +1,79 @@ -# version: '3.8' services: api: image: ${CONTAINER_IMAGE:-backend} volumes: - uploads_volume:/usr/src/app/uploads -# environment: -# PORT: 3000 -# DB_HOST: db -# DB_USER: postgres -# DB_NAME: say_dapp -# DB_PASS_FILE: /run/secrets/postgres-password -# secrets: -# - postgres-password -# networks: -# - default -# - traefik-public -# configs: -# - source: nest-config -# target: /usr/src/app/.env -# deploy: -# replicas: 1 -# update_config: -# parallelism: 1 -# order: start-first -# placement: -# constraints: -# - node.labels.${ENVIRONMENT} == true -# mode: replicated -# labels: -# - traefik.enable=true -# - traefik.docker.network=traefik-public -# - traefik.constraint-label=traefik-public -# - traefik.http.routers.${STACK_NAME}-api-http.entrypoints=http -# - traefik.http.routers.${STACK_NAME}-api-http.rule=Host(`${DOMAIN?Variable not set}`) -# - traefik.http.routers.${STACK_NAME}-api-http.service=${STACK_NAME}-api -# - traefik.http.routers.${STACK_NAME}-api-http.middlewares=https-redirect -# - traefik.http.routers.${STACK_NAME}-api.entrypoints=https -# - traefik.http.routers.${STACK_NAME}-api.rule=Host(`${DOMAIN?Variable not set}`) -# - traefik.http.routers.${STACK_NAME}-api.service=${STACK_NAME}-api -# - traefik.http.routers.${STACK_NAME}-api.tls=true -# - traefik.http.routers.${STACK_NAME}-api.tls.certresolver=le -# - traefik.http.services.${STACK_NAME}-api.loadbalancer.server.port=3000 + environment: + PORT: 3000 + DB_HOST: db + DB_USER: postgres + DB_NAME: say_dapp + DB_PASS_FILE: /run/secrets/postgres-password + secrets: + - postgres-password + networks: + - default + - traefik-public + configs: + - source: nest-config + target: /usr/src/app/.env + deploy: + replicas: 1 + update_config: + parallelism: 1 + order: start-first + placement: + constraints: + - node.labels.${ENVIRONMENT} == true + mode: replicated + labels: + - traefik.enable=true + - traefik.docker.network=traefik-public + - traefik.constraint-label=traefik-public + - traefik.http.routers.${STACK_NAME}-api-http.entrypoints=http + - traefik.http.routers.${STACK_NAME}-api-http.rule=Host(`${DOMAIN?Variable not set}`) + - traefik.http.routers.${STACK_NAME}-api-http.service=${STACK_NAME}-api + - traefik.http.routers.${STACK_NAME}-api-http.middlewares=https-redirect + - traefik.http.routers.${STACK_NAME}-api.entrypoints=https + - traefik.http.routers.${STACK_NAME}-api.rule=Host(`${DOMAIN?Variable not set}`) + - traefik.http.routers.${STACK_NAME}-api.service=${STACK_NAME}-api + - traefik.http.routers.${STACK_NAME}-api.tls=true + - traefik.http.routers.${STACK_NAME}-api.tls.certresolver=le + - traefik.http.services.${STACK_NAME}-api.loadbalancer.server.port=3000 -# db: -# image: postgres:12 -# secrets: -# - postgres-password -# environment: -# POSTGRES_DB: say_dapp -# POSTGRES_USER: postgres -# POSTGRES_PASSWORD_FILE: /run/secrets/postgres-password -# volumes: -# - postgres_volume:/var/lib/postgresql/data -# deploy: -# replicas: 1 -# update_config: -# parallelism: 1 -# order: stop-first -# placement: -# constraints: -# - node.labels.${ENVIRONMENT} == true + db: + image: postgres:12 + secrets: + - postgres-password + environment: + POSTGRES_DB: say_dapp + POSTGRES_USER: postgres + POSTGRES_PASSWORD_FILE: /run/secrets/postgres-password + volumes: + - postgres_volume:/var/lib/postgresql/data + deploy: + replicas: 1 + update_config: + parallelism: 1 + order: stop-first + placement: + constraints: + - node.labels.${ENVIRONMENT} == true volumes: postgres_volume: uploads_volume: +networks: + traefik-public: + external: true -# networks: -# traefik-public: -# external: true - -# secrets: -# postgres-password: -# name: ${STACK_NAME}-postgres-password -# external: true +secrets: + postgres-password: + name: ${STACK_NAME}-postgres-password + external: true -# configs: -# nest-config: -# name: ${STACK_NAME}.env -# external: true +configs: + nest-config: + name: ${STACK_NAME}.env + external: true \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 28f195c98..697529215 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,5 @@ -version: '3.3' +# version: '3.3' services: api: build: