Skip to content

Commit

Permalink
Merge branch 'master' into new_branch
Browse files Browse the repository at this point in the history
  • Loading branch information
ljy2855 committed Feb 16, 2024
2 parents 101c31f + 02954b2 commit fbd766a
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ jobs:
DJANGO_ALLOWED_HOSTS: ${{ secrets.DJANGO_ALLOWED_HOSTS }}
run: |
cd app
python manage.py makemigrations --settings=cspc_web.settings_dev
python manage.py migrate --settings=cspc_web.settings_dev
python manage.py test --settings=cspc_web.settings_dev
python manage.py makemigrations
python manage.py migrate
python manage.py test
29 changes: 29 additions & 0 deletions app/Dockerfile-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM python:3.8.13

# 환경 변수 설정
ENV HOME=/home/app
ENV APP_HOME=/home/app/web


# 애플리케이션 디렉터리 생성
RUN mkdir -p $APP_HOME
WORKDIR $APP_HOME

# 파이썬 실행 관련 환경 변수
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# requirements.txt 복사 및 설치
COPY ./requirements.txt $APP_HOME/requirements.txt
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir --upgrade -r requirements.txt

# .env 파일을 제외하고 모든 파일 복사
COPY . $APP_HOME
RUN rm -f $APP_HOME/.env

RUN sed -i 's/\r$//g' $APP_HOME/entrypoint-dev.sh

RUN chmod +x $APP_HOME/entrypoint-dev.sh

ENTRYPOINT [ "/home/app/web/entrypoint-dev.sh" ]
19 changes: 13 additions & 6 deletions app/cspc_web/settings_dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import os
from pathlib import Path
from dotenv import load_dotenv
from django.core.management.utils import get_random_secret_key
# Build paths inside the project like this: BASE_DIR / 'subdir'.

BASE_DIR = Path(__file__).resolve().parent.parent
Expand All @@ -23,12 +24,18 @@
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get('SECRET_KEY')
if os.environ.get("SECRET_KEY", None) == None:
random_key = get_random_secret_key()
f = open(".env", "a")
f.write(f"SECRET_KEY={random_key}")
SECRET_KEY = random_key
else:
SECRET_KEY = os.environ.get("SECRET_KEY")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ")
ALLOWED_HOSTS = ["*"]


REST_FRAMEWORK = {
Expand Down Expand Up @@ -104,7 +111,7 @@
DATABASES = {
'default': {
"ENGINE": "django.db.backends.sqlite3",
"NAME": "db.sqlite3"
"NAME": "db/db.sqlite3"

}
}
Expand All @@ -130,9 +137,9 @@
]

CSRF_TRUSTED_ORIGINS = [
'https://apply.cspc.me',
'http://localhost:8000',
]
'http://dev.cspc.me',
'https://dev.cspc.me'
]

# Internationalization
# https://docs.djangoproject.com/en/4.1/topics/i18n/
Expand Down
8 changes: 8 additions & 0 deletions app/entrypoint-dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh


python manage.py makemigrations --settings=cspc_web.settings_dev
python manage.py migrate --no-input --settings=cspc_web.settings_dev


exec "$@"
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ services:
- postgres_data:/var/lib/postgresql/data/
env_file:
- ./.env.db
dev_api:
build:
context: ./app
dockerfile: Dockerfile-dev
command: python manage.py runserver 0.0.0.0:8000 --settings=cspc_web.settings_dev
volumes:
- ./app/db:/home/app/web/db
ports:
- "8005:8000"
volumes:
postgres_data:
static_volunme:

0 comments on commit fbd766a

Please sign in to comment.