diff --git a/.github/workflows/build-and-deploy-api-gateway.yml b/.github/workflows/build-and-deploy-api-gateway.yml index 28496175..a8f99e93 100644 --- a/.github/workflows/build-and-deploy-api-gateway.yml +++ b/.github/workflows/build-and-deploy-api-gateway.yml @@ -3,7 +3,7 @@ name: build-and-deploy-api-gateway on: workflow_dispatch jobs: - build_and_deploy: + build: runs-on: ubuntu-latest name: Build images steps: @@ -45,6 +45,12 @@ jobs: run: docker build -t registry.digitalocean.com/linkerry/api-gateway:latest -f ./apps/api-gateway/Dockerfile . --platform=linux/amd64 - name: Push image to DO Container Registry run: docker push registry.digitalocean.com/linkerry/api-gateway:latest + - name: Clear DO container registry + run: doctl registry garbage-collection start + deploy: + runs-on: ubuntu-latest + name: Deploy api + steps: - name: Connect to VPS and refresh docker compose uses: appleboy/ssh-action@v1.0.3 with: @@ -55,7 +61,6 @@ jobs: port: 22 script: | cd api.linkerry.com/ - docker-compose pull - docker-compose up -d --no-deps --build api-gateway - - name: Clear DO container registry - run: doctl registry garbage-collection start + docker compose pull + docker compose up -d --no-deps --build api-gateway + docker image prune -f diff --git a/.github/workflows/build-and-deploy-app.yml b/.github/workflows/build-and-deploy-app.yml index c4fa5aec..3d75a174 100644 --- a/.github/workflows/build-and-deploy-app.yml +++ b/.github/workflows/build-and-deploy-app.yml @@ -52,3 +52,22 @@ jobs: run: docker build -t registry.digitalocean.com/linkerry/web:latest --build-arg NEXT_PUBLIC_API_HOST=$NEXT_PUBLIC_API_HOST -f ./apps/web/Dockerfile . --platform=linux/amd64 - name: Push image to DO Container Registry run: docker push registry.digitalocean.com/linkerry/web:latest + - name: Connect to VPS and refresh docker composes + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.VPS_IP }} + username: root + key: ${{ secrets.SSH_PASSPHRASE_PRIVATE_KEY }} + passphrase: ${{ secrets.SSH_PASSPHRASE }} + port: 22 + script: | + cd api.linkerry.com/ + docker compose pull + docker compose up -d --no-deps --build api-gateway + cd .. + cd linkerry.com/ + docker compose pull + docker compose up -d --no-deps --build web + docker image prune -f + - name: Clear DO container registry + run: doctl registry garbage-collection start diff --git a/.github/workflows/build-and-deploy-web.yml b/.github/workflows/build-and-deploy-web.yml index be99d2fb..73715afe 100644 --- a/.github/workflows/build-and-deploy-web.yml +++ b/.github/workflows/build-and-deploy-web.yml @@ -61,9 +61,8 @@ jobs: port: 22 script: | cd linkerry.com/ - docker-compose pull - docker compose up --force-recreate --build -d - docker-compose up -d --no-deps --build api-gateway + docker compose pull + docker compose up -d --no-deps --build web + docker image prune -f - name: Clear DO container registry run: doctl registry garbage-collection start - diff --git a/apps/web/docker-compose.prod.yml b/apps/web/docker-compose.prod.yml index 10bbe444..f1869cd7 100644 --- a/apps/web/docker-compose.prod.yml +++ b/apps/web/docker-compose.prod.yml @@ -1,6 +1,7 @@ version: '3.8' services: web: + container_name: web image: registry.digitalocean.com/linkerry/web:latest ports: - ${VIRTUAL_PORT}:${VIRTUAL_PORT}