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 : settings.py 환경변수 에러 수정 #97

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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: 14 additions & 6 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,21 @@ jobs: # Job
# 이미지 빌드를 위해 .env 생성
- name: Setting .env
run: |
echo "${{ secrets.ENV }}" >> .env
cat .env
# echo "${{ secrets.ENV }}" >> .env
echo "DATABASE_NAME=${{ secrets.DATABASE_NAME }}" >> .env
echo "DATABASE_USER=${{ secrets.DATABASE_USER }}" >> .env
echo "DATABASE_PASSWORD=${{ secrets.DATABASE_PASSWORD }}" >> .env
echo "DATABASE_HOST=${{ secrets.DATABASE_HOST }}" >> .env
echo "DATABASE_PORT=${{ secrets.DATABASE_PORT }}" >> .env
echo "SECRET_KEY=${{ secrets.SECRET_KEY }}" >> .env
# ... add other variables
cat .env


# docker-compose에서 사용하는 이미지들을 build, 공식 이미지들은 x
- name: Build docker images
run: |
docker-compose -f docker-compose.yml build
docker images
run: docker-compose -f docker-compose.yml build
# docker images

# docker hub repository에 이미지들을 push
- name: Push docker images
Expand All @@ -59,8 +66,9 @@ jobs: # Job
key: ${{ secrets.AWS_KEY_PEM }}
envs: GITHUB_SHA
script: |
cd NextPage/
cd NextPage/backend/
git pull
cd ../
sudo docker-compose -f docker-compose.yml -f docker-compose.monitoring.yml down
sudo docker-compose -f docker-compose.yml -f docker-compose.monitoring.yml pull
sudo docker-compose -f docker-compose.yml -f docker-compose.monitoring.yml up -d --build
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python manage.py migrate
- name: Run Tests
env:
DATABASE_NAME: ${{ secrets.DATABASE_NAME }}
Expand Down
17 changes: 7 additions & 10 deletions backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import os
import sys
from pathlib import Path
# from .mysettings import MY_DATABASES, MY_DATABASE_URL, MY_SECRET
from dotenv import load_dotenv

load_dotenv() # env 파일에 있는 값 얻어오기
Expand Down Expand Up @@ -145,16 +144,16 @@
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': os.environ.get('DATABASE_NAME', 'default_db_name'),
'USER': os.environ.get('DATABASE_USER', 'default_user'),
'PASSWORD': os.environ.get('DATABASE_PASSWORD', 'default_password'),
'HOST': os.environ.get('DATABASE_HOST', 'localhost'),
'PORT': os.environ.get('DATABASE_PORT', '3306'),
'NAME': os.environ.get('DATABASE_NAME'),
'USER': os.environ.get('DATABASE_USER'),
'PASSWORD': os.environ.get('DATABASE_PASSWORD'),
'HOST': os.environ.get('DATABASE_HOST'),
'PORT': os.environ.get('DATABASE_PORT'),
}
}

DATABASE_URL = os.environ.get('DATABASE_URL', "default_database_url")
SECRET_KEY = os.environ.get('SECRET_KEY', 'default_secret_key')
DATABASE_URL = os.environ.get('DATABASE_URL')
SECRET_KEY = os.environ.get('SECRET_KEY')

# Password validation
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
Expand Down Expand Up @@ -226,6 +225,4 @@
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
MEDIA_URL = f'https://{AWS_S3_CUSTOM_DOMAIN}/'

#정적 파일 불러오기
STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, '_static')