Skip to content

Commit

Permalink
docker/pipeline changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan-g committed Aug 14, 2024
1 parent 8d71c68 commit 3996d83
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 71 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
Expand Down Expand Up @@ -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 }}
script: docker stack deploy --prune --resolve-image=changed --with-registry-auth -c /tmp/${{ env.STACK_FILE }} ${{ env.PRODUCTION_STACK_NAME }}
134 changes: 66 additions & 68 deletions docker-compose.production.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

version: '3.3'
# version: '3.3'
services:
api:
build:
Expand Down

0 comments on commit 3996d83

Please sign in to comment.