-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (41 loc) · 1.46 KB
/
Dockerfile
File metadata and controls
57 lines (41 loc) · 1.46 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
FROM python:3.11-slim AS builder
WORKDIR /build
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1 \
PATH="/opt/venv/bin:${PATH}"
COPY requirements.txt ./
RUN python -m venv /opt/venv \
&& apt-get update \
&& apt-get install -y --no-install-recommends build-essential python3-dev \
&& pip install --upgrade pip \
&& grep -v '^torch==' requirements.txt > requirements.runtime.txt \
&& pip install --no-cache-dir -r requirements.runtime.txt \
&& pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu torch==2.2.2 \
&& python -m spacy download ko_core_news_sm \
&& rm -rf /var/lib/apt/lists/* /root/.cache /tmp/*
FROM python:3.11-slim AS runtime
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1 \
PATH="/opt/venv/bin:${PATH}" \
APP_MODE=server \
APP_HOST=0.0.0.0 \
APP_PORT=8000
RUN addgroup --system appgroup \
&& adduser --system --ingroup appgroup --home /app appuser
RUN apt-get update \
&& apt-get install -y --no-install-recommends libgomp1 \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /opt/venv /opt/venv
COPY app ./app
COPY scripts ./scripts
COPY docker-entrypoint.sh ./docker-entrypoint.sh
RUN chmod +x /app/docker-entrypoint.sh \
&& chown -R appuser:appgroup /app
USER appuser
EXPOSE 8000
ENTRYPOINT ["/app/docker-entrypoint.sh"]