-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
59 lines (44 loc) · 1.45 KB
/
Dockerfile
File metadata and controls
59 lines (44 loc) · 1.45 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# 📌 Base 이미지 선택
FROM python:3.10-slim as builder
# 작업 디렉토리 설정
WORKDIR /app
# 시스템 패키지 설치
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
# Poetry 설치
RUN curl -sSL https://install.python-poetry.org | python3 -
# 의존성 파일 복사
COPY pyproject.toml poetry.lock ./
# 의존성 설치
RUN poetry config virtualenvs.create false \
&& poetry install --no-dev --no-interaction --no-ansi
# 프로덕션 이미지
FROM python:3.10-slim
WORKDIR /app
# 필요한 시스템 패키지만 설치
RUN apt-get update && apt-get install -y --no-install-recommends \
libpq-dev \
curl \
&& rm -rf /var/lib/apt/lists/*
# 빌더 스테이지에서 설치된 패키지 복사
COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
# 애플리케이션 코드 복사
COPY . .
# 환경 변수 설정
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
ENV PORT=8000
ENV PROMETHEUS_MULTIPROC_DIR=/tmp
ENV LOG_LEVEL=INFO
# 로그 및 프로메테우스 메트릭 디렉토리 생성
RUN mkdir -p /app/logs /tmp \
&& chmod -R 777 /app/logs /tmp
# 헬스체크 설정
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:${PORT}/health || exit 1
# 실행 권한 설정
RUN chmod +x /app/scripts/start.sh
# 실행
CMD ["/app/scripts/start.sh"]