Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: aws 인스턴스에 환경변수 전달 안되는 문제 수정 및 docker compose 파일 db에 의존성 가지게 수정 #5

Merged
merged 6 commits into from
Jul 20, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions .github/workflows/deploy-workflow.yml
Original file line number Diff line number Diff line change
@@ -57,14 +57,18 @@ jobs:
username: ${{ secrets.SERVER_USER_NAME }}
key: ${{ secrets.SERVER_PRIVATE_KEY }}
script: |
export SERVER_NGINX_CONF=${{ secrets.SERVER_NGINX_CONF }}
export SERVER_USER_NAME=${{ secrets.SERVER_USER_NAME }}
export DOCKER_USERNAME=${{ secrets.DOCKER_USERNAME }}
export DOCKER_TAG=${{ env.DATETIME_TAG }}
export DB_DATABASE=${{ secrets.DB_DATABASE }}
export DB_USER_NAME=${{ secrets.DB_USER_NAME }}
export DB_PASSWORD=${{ secrets.DB_PASSWORD }}
export DISCORD_WEBHOOK_URL=${{ secrets.DISCORD_WEBHOOK_URL }}
if [ -f /home/$SERVER_USER_NAME/deploy/env_vars.sh ]; then
rm /home/$SERVER_USER_NAME/deploy/env_vars.sh
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SERVER_USER_NAME도 ${{ secrets.SERVER_USER_NAME }} 이렇게 해야하지 않을까요?!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 감사합니다 수정했어요!!


echo "SERVER_NGINX_CONF=${{ secrets.SERVER_NGINX_CONF }}" > /home/$SERVER_USER_NAME/deploy/env_vars.sh
Copy link
Collaborator Author

@injoon2019 injoon2019 Jul 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

일단 디버깅도 할겸 파일로 써볼까 합니다! export가 해당 세션 및 자식 세션에서 환경 변수가 유지된다고 하는데 끊기는건가 싶기도하네요

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋아요! 이상하게 deploy.sh -> notify_error.sh 까지 환경변수가 잘 전달되는데 docker-compose.yml에서만 인식을 못하더라구요..

echo "SERVER_USER_NAME=${{ secrets.SERVER_USER_NAME }}" >> /home/$SERVER_USER_NAME/deploy/env_vars.sh
echo "DOCKER_USERNAME=${{ secrets.DOCKER_USERNAME }}" >> /home/$SERVER_USER_NAME/deploy/env_vars.sh
echo "DOCKER_TAG=${{ env.DATETIME_TAG }}" >> /home/$SERVER_USER_NAME/deploy/env_vars.sh
echo "DB_DATABASE=${{ secrets.DB_DATABASE }}" >> /home/$SERVER_USER_NAME/deploy/env_vars.sh
echo "DB_USER_NAME=${{ secrets.DB_USER_NAME }}" >> /home/$SERVER_USER_NAME/deploy/env_vars.sh
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> /home/$SERVER_USER_NAME/deploy/env_vars.sh
echo "DISCORD_WEBHOOK_URL=${{ secrets.DISCORD_WEBHOOK_URL }}" >> /home/$SERVER_USER_NAME/deploy/env_vars.sh

cd /home/$SERVER_USER_NAME/deploy
sudo chmod +x deploy.sh notify_error.sh
2 changes: 2 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

source /home/$SERVER_USER_NAME/deploy/env_vars.sh

sudo docker pull ${DOCKER_USERNAME}/bottles:${DOCKER_TAG}
cd ../docker
docker-compose up -d
4 changes: 1 addition & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.8'

services:
nginx:
container_name: nginx
@@ -19,7 +17,7 @@ services:
ports:
- "8080:8080"
depends_on:
- mysql
- db
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 아래 db에 의존성이 있는거 같아 수정했어요!


db:
container_name: mysql