-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (35 loc) · 1.36 KB
/
Dockerfile
File metadata and controls
44 lines (35 loc) · 1.36 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
FROM python:3.10-slim AS builder
ENV PIP_NO_CACHE_DIR=1
WORKDIR /app
# 캐시 최적화를 위해 패키지 설치를 분리
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# requirements.txt 먼저 복사하여 의존성 캐싱 최적화
COPY requirements.txt .
RUN --mount=type=cache,target=/root/.cache/pip \
python -m venv /opt/venv \
&& /opt/venv/bin/pip install --upgrade pip \
&& /opt/venv/bin/pip install -r requirements.txt
FROM python:3.10-slim
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PATH="/opt/venv/bin:$PATH"
WORKDIR /app
# 런타임 의존성만 설치
RUN apt-get update && apt-get install -y --no-install-recommends \
curl libpq5 libjpeg62-turbo zlib1g \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# venv 복사
COPY --from=builder /opt/venv /opt/venv
# 소스코드 복사 (마지막에 복사하여 캐시 활용)
COPY . .
# 정적파일 및 미디어 디렉토리 생성
RUN mkdir -p /app/staticfiles /app/media
# entrypoint 스크립트 복사 및 실행 권한 부여
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
EXPOSE 8000
ENTRYPOINT ["/entrypoint.sh"]
CMD ["gunicorn", "config.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "2", "--timeout", "120", "--max-requests", "1000", "--max-requests-jitter", "50"]