Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- 로깅 서버
- GNNExplainer
- DevOps
- Graph Neural Network
- Heterogeneous Graphs
- cs224w
- cloudsql
- ML/DL
- IaaC
- auto reload
- argocd
- npm7
- 영화 리뷰
- auto-reload
- boj2352
- SCP294
- django
- SCP 재단
- Terraform
- BigQuery
- ngrok
- GNN
- Terragrunt
- 2352
- docker compose
- 영화 추천
- RGCN
- KG embedding
- knowledge graph
- the platform
Archives
- Today
- Total
Itmom's blog
Docker compose 이용 시 Django auto reload 본문
1. Dockerfile / docker-compose.yml 작성
docker-compose를 이용해 django local 개발 환경을 구성하려고 했다. 작성한 Dockerfile / docker-compose.yml은 다음과 같다.
Dockerfile
# Release Image
FROM python:3.7
WORKDIR /src
RUN pip install --upgrade pip
COPY . .
RUN pip install -r requirements.txt
WORKDIR /src/base
ARG SECRET_KEY
ARG DEBUG=False
RUN echo "SECRET_KEY="$SECRET_KEY >> .env
RUN echo "DEBUG="$DEBUG >> .env
WORKDIR /src
EXPOSE 8000
CMD ["gunicorn", "--bind", "0:8000", "base.wsgi:application"]
docker-compose.yml
version: "3"
services:
app:
restart: "on-failure"
build:
context: ./
dockerfile: Dockerfile
platform: "linux/amd64"
environment:
DEBUG: True
SECRET_KEY: temp
expose:
- "8000"
ports:
- "8000:8000"
depends_on:
- db
db:
restart: always
image: postgres
volumes:
- ./init-db/:/docker-entrypoint-initdb.d/
ports:
- "5432:5432"
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
- POSTGRES_USER=user
- POSTGRES_PASSWORD=1234
2. Auto reload 문제 해결
docker compose up
으로 local server를 시작해주었는데.. 왠걸! python [manage.py](http://manage.py) runserver
로 명령어를 실행할 때와 달리 코드를 수정해도 auto-reload가 이루어지지 않았다. docker-compose에 volume을 추가해주어 해결할 수 있었다. 수정된 docker-compose.yml은 다음과 같다.
version: "3"
services:
app:
restart: "on-failure"
build:
context: ./
dockerfile: Dockerfile
platform: "linux/amd64"
environment:
DEBUG: True
SECRET_KEY: h+h-5fescy_u7*6v1_da
expose:
- "8000"
ports:
- "8000:8000"
volumes:
- ./:/src
depends_on:
- db
db:
restart: always
image: postgres
volumes:
- ./init-db/:/docker-entrypoint-initdb.d/
ports:
- "5432:5432"
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
- POSTGRES_USER=user
- POSTGRES_PASSWORD=1234
'Development > Backend' 카테고리의 다른 글
Linux File System과 Virtual File System (0) | 2022.02.26 |
---|---|
Django 개발 환경별 postgresql 연결 셋팅 (0) | 2022.02.26 |