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 환경변수 에러 수정 #96

Closed
wants to merge 3 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
17 changes: 12 additions & 5 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 Down
23 changes: 13 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,21 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
setup-python-path: true
- 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 }}
DATABASE_USER: ${{ secrets.DATABASE_USER }}
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
DATABASE_HOST: ${{ secrets.DATABASE_HOST }}
DATABASE_PORT: ${{ secrets.DATABASE_PORT }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
run: |
python manage.py test
run: python manage.py test
# env:
# DATABASE_NAME: ${{ secrets.DATABASE_NAME }}
# DATABASE_USER: ${{ secrets.DATABASE_USER }}
# DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
# DATABASE_HOST: ${{ secrets.DATABASE_HOST }}
# DATABASE_PORT: ${{ secrets.DATABASE_PORT }}
# DATABASE_URL: ${{ secrets.DATABASE_URL }}
# SECRET_KEY: ${{ secrets.SECRET_KEY }}
# run: |
# python manage.py test
41 changes: 21 additions & 20 deletions backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
import os
import sys
from pathlib import Path
# from .mysettings import MY_DATABASES, MY_DATABASE_URL, MY_SECRET

from backend.mysettings import MY_DATABASES, MY_DATABASE_URL, MY_SECRET
from dotenv import load_dotenv

load_dotenv() # env 파일에 있는 값 얻어오기
Expand All @@ -23,7 +24,7 @@
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/

# SECRET_KEY = MY_SECRET
SECRET_KEY = MY_SECRET

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
Expand Down Expand Up @@ -136,25 +137,25 @@
# Database
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases

# # Neo4j 데이터베이스 설정
# DATABASE_URL = MY_DATABASE_URL
# Neo4j 데이터베이스 설정
DATABASE_URL = MY_DATABASE_URL

# mysql db 연동
DATABASES = MY_DATABASES

# 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'),
# }
# }
#
# # mysql db 연동
# DATABASES = MY_DATABASES

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'),
}
}

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', "default_database_url")
# SECRET_KEY = os.environ.get('SECRET_KEY', 'default_secret_key')

# Password validation
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
Expand Down
Loading