Skip to content

Commit

Permalink
feat: docker에서 redoc 사용 가능하게 함 (GunGonGamLee#416)
Browse files Browse the repository at this point in the history
* build: 백엔드 컨테이너에 프론트엔드의 아바타 폴더 볼륨 연결

- 아바타 업로드를 위함

* build: 백엔드 static 파일은 nginx에 연결

* build: static_volume 대신 backend static 볼륨 마운트

* feat: debug = False여도 redoc은 동작하게 함

* build: init.sh 파일 실행 위치 변경

- backend.src 모듈을 못 찾는 관계로 init.sh을 컨테이너의 루트가 아닌 backend 폴더의 루트로 옮김

* build: 백엔드 daphne 설정 시 필요한 .env 복사

* build: env path 수정

- env path를 기존 /backend/../.env에서 /.env로 수정

* build: static-volume으로 백엔드 static 파일 관리
  • Loading branch information
nyj001012 authored Mar 8, 2024
1 parent 1dbbe4a commit 9ed0568
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM python:3.12.1-slim

COPY .env .env

RUN mkdir -p backend && \
mkdir -p /var/log/djangolog && \
apt-get update && \
Expand All @@ -14,7 +16,7 @@ ENV DJANGO_SETTINGS_MODULE=src.settings
COPY backend ./backend
WORKDIR /backend

COPY init.sh /init.sh
RUN chmod +x /init.sh
COPY init.sh ./init.sh
RUN chmod +x ./init.sh

ENTRYPOINT ["/init.sh"]
ENTRYPOINT ["./init.sh"]
3 changes: 2 additions & 1 deletion backend/src/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from pythonjsonlogger import jsonlogger

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
ENV_PATH = os.path.join(BASE_DIR, '..', '.env')
BASE_DIR_PATH = Path(__file__).resolve().parent.parent.parent
ENV_PATH = BASE_DIR_PATH / '.env'
env = environ.Env()
DEBUG = False
env.read_env(env_file=ENV_PATH)
Expand Down
4 changes: 2 additions & 2 deletions backend/src/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
urlpatterns = [
path('admin/', admin.site.urls),
path('api/', include('api.urls')),
re_path(r'^redoc/$', schema_view.with_ui('redoc',
cache_timeout=0), name='schema-redoc'),
]

# DEBUG 모드일 경우, ui 없이 swagger view를 사용할 수 있도록 설정
Expand All @@ -47,6 +49,4 @@
schema_view.without_ui(cache_timeout=0), name='schema-json'),
re_path(r'^swagger/$', schema_view.with_ui('swagger',
cache_timeout=0), name='schema-swagger-ui'),
re_path(r'^redoc/$', schema_view.with_ui('redoc',
cache_timeout=0), name='schema-redoc'),
]
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ services:
networks:
- app_network
volumes:
- ./frontend/assets/images/avatar:/frontend/assets/images/avatar
- static-volume:/backend/static
- "${CERTS_PATH}:/backend/certs"
- "${DJANGO_LOGS}:/var/log/djangolog"
Expand Down

0 comments on commit 9ed0568

Please sign in to comment.