Skip to content

Commit

Permalink
CICD: env 파일 분리, 서버 docker image tag 분리 (#248)
Browse files Browse the repository at this point in the history
* CICD: Seperate docker image tag of prod, dev, rename env

* CICD: Change env name of db

* CICD: Change env name of proxy

* CICD: Remove unused latest tag

---------

Co-authored-by: Junhyeong Kim <leeeryboy@gmail.com>
  • Loading branch information
huGgW and leeeryboy authored Apr 6, 2024
1 parent 58455b7 commit ffde429
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 50 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/database.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
-
name: Create .env file
run: |
echo "MYSQL_ROOT_PASSWORD=${{secrets.MYSQL_ROOT_PASSWORD}}" > .env
echo "MYSQL_USER=${{secrets.MYSQL_USER}}" >> .env
echo "MYSQL_PASSWORD=${{secrets.MYSQL_PASSWORD}}" >> .env
echo "MYSQL_DATABASE=${{secrets.MYSQL_DATABASE}}" >> .env
echo "MYSQL_ROOT_PASSWORD=${{secrets.MYSQL_ROOT_PASSWORD}}" > .env_db
echo "MYSQL_USER=${{secrets.MYSQL_USER}}" >> .env_db
echo "MYSQL_PASSWORD=${{secrets.MYSQL_PASSWORD}}" >> .env_db
echo "MYSQL_DATABASE=${{secrets.MYSQL_DATABASE}}" >> .env_db
-
name: SCP Command to Transfer Files
Expand All @@ -35,7 +35,7 @@ jobs:
username: ${{secrets.SSH_USER}}
port: ${{secrets.SSH_PORT}}
key: ${{secrets.SSH_KEY}}
source: "docker-compose-db.yml, .env"
source: "docker-compose-db.yml, .env_db"
target: "~/app"
overwrite: true

Expand All @@ -49,6 +49,6 @@ jobs:
key: ${{secrets.SSH_KEY}}
script: |
cd ~/app
source .env
source .env_db
docker compose -f docker-compose-db.yml down
docker compose -f docker-compose-db.yml up -d
12 changes: 6 additions & 6 deletions .github/workflows/database_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
-
name: Create .env file
run: |
echo "MYSQL_ROOT_PASSWORD=${{secrets.MYSQL_ROOT_PASSWORD}}" > .env
echo "MYSQL_USER=${{secrets.MYSQL_USER}}" >> .env
echo "MYSQL_PASSWORD=${{secrets.MYSQL_PASSWORD}}" >> .env
echo "MYSQL_DATABASE=${{secrets.MYSQL_DATABASE}}" >> .env
echo "MYSQL_ROOT_PASSWORD=${{secrets.MYSQL_ROOT_PASSWORD}}" > .env_db
echo "MYSQL_USER=${{secrets.MYSQL_USER}}" >> .env_db
echo "MYSQL_PASSWORD=${{secrets.MYSQL_PASSWORD}}" >> .env_db
echo "MYSQL_DATABASE=${{secrets.MYSQL_DATABASE}}" >> .env_db
-
name: SCP Command to Transfer Files
Expand All @@ -34,7 +34,7 @@ jobs:
host: ${{secrets.SSH_HOST_DEV}}
username: ${{secrets.SSH_USER}}
key: ${{secrets.SSH_KEY}}
source: "docker-compose-db.yml, .env"
source: "docker-compose-db.yml, .env_db"
target: "~/app"
overwrite: true

Expand All @@ -47,6 +47,6 @@ jobs:
key: ${{secrets.SSH_KEY}}
script: |
cd ~/app
source .env
source .env_db
docker-compose -f docker-compose-db.yml down
docker-compose -f docker-compose-db.yml up -d
24 changes: 12 additions & 12 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ jobs:
build-args: |
PROFILE=prod
tags: |
ghcr.io/wafflestudio/csereal-server/server_image:latest
ghcr.io/wafflestudio/csereal-server/server_image:prod
ghcr.io/wafflestudio/csereal-server/server_image:${{github.sha}}
- name: Create .env file
run: |
echo "MYSQL_ROOT_PASSWORD=${{secrets.MYSQL_ROOT_PASSWORD}}" > .env
echo "MYSQL_USER=${{secrets.MYSQL_USER}}" >> .env
echo "MYSQL_PASSWORD=${{secrets.MYSQL_PASSWORD}}" >> .env
echo "MYSQL_DATABASE=${{secrets.MYSQL_DATABASE}}" >> .env
echo "PROFILE=prod" >> .env
echo "OIDC_CLIENT_SECRET=${{secrets.OIDC_CLIENT_SECRET}}" >> .env
echo "URL=${{secrets.URL}}" >> .env
echo "SLACK_TOKEN=${{secrets.SLACK_TOKEN}}" >> .env
echo "SLACK_CHANNEL=${{secrets.SLACK_CHANNEL}}" >> .env
echo "PROFILE=prod" > .env_server
echo "MYSQL_ROOT_PASSWORD=${{secrets.MYSQL_ROOT_PASSWORD}}" >> .env_server
echo "MYSQL_USER=${{secrets.MYSQL_USER}}" >> .env_server
echo "MYSQL_PASSWORD=${{secrets.MYSQL_PASSWORD}}" >> .env_server
echo "MYSQL_DATABASE=${{secrets.MYSQL_DATABASE}}" >> .env_server
echo "OIDC_CLIENT_SECRET=${{secrets.OIDC_CLIENT_SECRET}}" >> .env_server
echo "URL=${{secrets.URL}}" >> .env_server
echo "SLACK_TOKEN=${{secrets.SLACK_TOKEN}}" >> .env_server
echo "SLACK_CHANNEL=${{secrets.SLACK_CHANNEL}}" >> .env_server
- name: SCP Command to Transfer Files
uses: appleboy/scp-action@v0.1.4
Expand All @@ -70,7 +70,7 @@ jobs:
username: ${{secrets.SSH_USER}}
port: ${{secrets.SSH_PORT}}
key: ${{secrets.SSH_KEY}}
source: "docker-compose-backend.yml, .env"
source: "docker-compose-backend.yml, .env_server"
target: "~/app"
overwrite: true
- name: SSH Remote Commands
Expand All @@ -82,7 +82,7 @@ jobs:
key: ${{secrets.SSH_KEY}}
script: |
cd ~/app
source .env
source .env_server
docker compose -f docker-compose-backend.yml down
docker compose -f docker-compose-backend.yml pull
docker compose -f docker-compose-backend.yml up -d
26 changes: 13 additions & 13 deletions .github/workflows/deploy_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,30 @@ jobs:
context: .
push: true
build-args: |
PROFILE=prod
PROFILE=dev
tags: |
ghcr.io/wafflestudio/csereal-server/server_image:latest
ghcr.io/wafflestudio/csereal-server/server_image:dev
ghcr.io/wafflestudio/csereal-server/server_image:${{github.sha}}
- name: Create .env file
run: |
echo "MYSQL_ROOT_PASSWORD=${{secrets.MYSQL_ROOT_PASSWORD}}" > .env
echo "MYSQL_USER=${{secrets.MYSQL_USER}}" >> .env
echo "MYSQL_PASSWORD=${{secrets.MYSQL_PASSWORD}}" >> .env
echo "MYSQL_DATABASE=${{secrets.MYSQL_DATABASE}}" >> .env
echo "PROFILE=dev" >> .env
echo "OIDC_CLIENT_SECRET=${{secrets.OIDC_CLIENT_SECRET}}" >> .env
echo "URL=${{secrets.URL_DEV}}" >> .env
# echo "SLACK_TOKEN=${{secrets.SLACK_TOKEN}}" >> .env
# echo "SLACK_CHANNEL=${{secrets.SLACK_CHANNEL}}" >> .env
echo "PROFILE=dev" > .env_server
echo "MYSQL_ROOT_PASSWORD=${{secrets.MYSQL_ROOT_PASSWORD}}" >> .env_server
echo "MYSQL_USER=${{secrets.MYSQL_USER}}" >> .env_server
echo "MYSQL_PASSWORD=${{secrets.MYSQL_PASSWORD}}" >> .env_server
echo "MYSQL_DATABASE=${{secrets.MYSQL_DATABASE}}" >> .env_server
echo "OIDC_CLIENT_SECRET=${{secrets.OIDC_CLIENT_SECRET}}" >> .env_server
echo "URL=${{secrets.URL_DEV}}" >> .env_server
# echo "SLACK_TOKEN=${{secrets.SLACK_TOKEN}}" >> .env_server
# echo "SLACK_CHANNEL=${{secrets.SLACK_CHANNEL}}" >> .env_server
- name: SCP Command to Transfer Files
uses: appleboy/scp-action@v0.1.4
with:
host: ${{secrets.SSH_HOST_DEV}}
username: ${{secrets.SSH_USER}}
key: ${{secrets.SSH_KEY}}
source: "docker-compose-backend.yml, .env"
source: "docker-compose-backend.yml, .env_server"
target: "~/app"
overwrite: true
- name: SSH Remote Commands
Expand All @@ -80,7 +80,7 @@ jobs:
key: ${{secrets.SSH_KEY}}
script: |
cd ~/app
source .env
source .env_server
docker-compose -f docker-compose-backend.yml down
docker-compose -f docker-compose-backend.yml pull
docker-compose -f docker-compose-backend.yml up -d
8 changes: 4 additions & 4 deletions .github/workflows/proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
-
name: Create .env file
run: |
echo "URL=${{secrets.URL}}" > .env
echo "LOCAL_IP=${{secrets.LOCAL_IP}}" >> .env
echo "URL=${{secrets.URL}}" > .env_proxy
echo "LOCAL_IP=${{secrets.LOCAL_IP}}" >> .env_proxy
-
name: SCP Command to Transfer Files
Expand All @@ -30,7 +30,7 @@ jobs:
username: ${{secrets.SSH_USER}}
port: ${{secrets.SSH_PORT}}
key: ${{secrets.SSH_KEY}}
source: "docker-compose-caddy.yml, .env, caddy/Caddyfile"
source: "docker-compose-caddy.yml, .env_proxy, caddy/Caddyfile"
target: "~/proxy"
overwrite: true

Expand All @@ -44,6 +44,6 @@ jobs:
key: ${{secrets.SSH_KEY}}
script: |
cd ~/proxy
source .env
source .env_proxy
docker compose -f docker-compose-caddy.yml down
docker compose -f docker-compose-caddy.yml up -d
8 changes: 4 additions & 4 deletions .github/workflows/proxy_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
-
name: Create .env file
run: |
echo "URL=${{secrets.URL_DEV}}" > .env
echo "LOCAL_IP=${{secrets.LOCAL_IP_DEV}}" >> .env
echo "URL=${{secrets.URL_DEV}}" > .env_proxy
echo "LOCAL_IP=${{secrets.LOCAL_IP_DEV}}" >> .env_proxy
-
name: SCP Command to Transfer Files
Expand All @@ -29,7 +29,7 @@ jobs:
host: ${{secrets.SSH_HOST_DEV}}
username: ${{secrets.SSH_USER}}
key: ${{secrets.SSH_KEY}}
source: "docker-compose-caddy.yml, .env, caddy/Caddyfile"
source: "docker-compose-caddy.yml, .env_proxy, caddy/Caddyfile"
target: "~/proxy"
overwrite: true

Expand All @@ -42,6 +42,6 @@ jobs:
key: ${{secrets.SSH_KEY}}
script: |
cd ~/proxy
source .env
source .env_proxy
docker-compose -f docker-compose-caddy.yml down
docker-compose -f docker-compose-caddy.yml up -d
6 changes: 1 addition & 5 deletions docker-compose-backend.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
services:
green:
container_name: csereal_server_green
build:
context: ./
args:
PROFILE: ${PROFILE}
ports:
- 8080:8080
volumes:
Expand All @@ -22,4 +18,4 @@ services:
extra_hosts:
- host.docker.internal:host-gateway
restart: always
image: ghcr.io/wafflestudio/csereal-server/server_image:latest
image: "ghcr.io/wafflestudio/csereal-server/server_image:${PROFILE}"

0 comments on commit ffde429

Please sign in to comment.