Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
leobang17 committed Sep 21, 2024
1 parent 83983df commit dfb8109
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 9 deletions.
28 changes: 19 additions & 9 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,22 @@ jobs:
with:
username: ${{ secrets.NCP_ACCESS_KEY }}
password: ${{ secrets.NCP_SECRET_KEY }}
- name: Set Docker image tag and environment file
id: vars
run: |
echo "IMAGE_TAG=dev" >> $GITHUB_ENV
echo "ENV_VARS=${{ secrets.DEV_ENV }}" >> $GITHUB_ENV
echo "ENV_FILE=.env.dev" >> $GITHUB_ENV
echo "DOCKER_COMPOSE_FILE=docker-compose-dev.yaml" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: ./apps/Dockerfile.app
push: true
tags: ${{ secrets.NCP_CONTAINER_REGISTRY_URL }}/${{ matrix.service }}:latest
tags: ${{ secrets.NCP_CONTAINER_REGISTRY_URL }}/${{ matrix.service }}:${{ env.IMAGE_TAG }}
build-args: |
PKG_NAME=@apps/${{ matrix.service }}
PORT=3000
Expand All @@ -52,22 +60,24 @@ jobs:

- name: Create .env file for remote server
run: |
echo "${{ secrets.DEV_ENV }}" > .env
echo "${{ env.ENV_VARS }}" > ${{ env.ENV_FILE }}
- name: Copy docker-compose file
uses: garygrossgarten/github-action-scp@release
with:
local: ./docker-compose-server.yaml
remote: apps/docker-compose-server.yaml
local: ./${{ env.DOCKER_COMPOSE_FILE }}
remote: apps/${{ env.DOCKER_COMPOSE_FILE}}
host: ${{ secrets.NCP_SERVER_HOST }}
username: ${{ secrets.NCP_SERVER_USERNAME }}
password: ${{ secrets.NCP_SERVER_PASSWORD }}

- name: Copy .env file to remote server
uses: garygrossgarten/github-action-scp@release
with:
local: ./.env
remote: apps/.env
# local: ./.env
# remote: apps/.env
local: ${{ env.ENV_FILE }}
remote: apps/${{ env.ENV_FILE }}
host: ${{ secrets.NCP_SERVER_HOST }}
username: ${{ secrets.NCP_SERVER_USERNAME }}
password: ${{ secrets.NCP_SERVER_PASSWORD }}
Expand All @@ -80,6 +90,6 @@ jobs:
password: ${{ secrets.NCP_SERVER_PASSWORD }}
port: 22
script: |
docker-compose -f apps/docker-compose-server.yaml down
docker-compose -f apps/docker-compose-server.yaml pull
docker-compose -f apps/docker-compose-server.yaml up -d
docker-compose -f apps/${{ env.DOCKER_COMPOSE_FILE}} down
docker-compose -f apps/${{ env.DOCKER_COMPOSE_FILE}} pull
docker-compose -f apps/${{ env.DOCKER_COMPOSE_FILE}} up -d
61 changes: 61 additions & 0 deletions docker-compose-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
version: '3.8'

services:
api-gateway:
image: 'leobang/api-gateway:dev'
container_name: api-gateway-dev
env_file:
- .env.dev
ports:
- '4000:3000'
restart: 'always'
networks:
- imc-docker-bridge-dev

auth:
image: 'leobang/auth:dev'
container_name: auth-dev
env_file:
- .env.dev
ports:
- '4001:3000'
restart: 'always'
networks:
- imc-docker-bridge-dev

inbox:
image: 'leobang/inbox:dev'
container_name: inbox-dev
env_file:
- .env.dev
ports:
- '4002:3000'
restart: 'always'
networks:
- imc-docker-bridge-dev

user:
image: 'leobang/user:dev'
container_name: user-dev
env_file:
- .env.dev
ports:
- '4003:3000'
restart: 'always'
networks:
- imc-docker-bridge-dev

mail-integrator:
image: 'leobang/mail-integrator:dev'
container_name: mail-integrator-dev
env_file:
- .env.dev
ports:
- '4004:3000'
restart: 'always'
networks:
- imc-docker-bridge-dev

networks:
imc-docker-bridge-dev:
external: true

0 comments on commit dfb8109

Please sign in to comment.