-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
75 lines (48 loc) · 1.98 KB
/
Dockerfile
File metadata and controls
75 lines (48 loc) · 1.98 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
FROM python:3.10-slim AS backend-builder
WORKDIR /build/backend
ARG TORCH_PACKAGE=torch
ARG TORCH_INDEX_URL=https://download.pytorch.org/whl/cpu
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH" \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1
COPY backend/requirements.txt ./
# The app runs as a regular CPU container in compose, so we preinstall the
# CPU-only PyTorch wheel to avoid pulling in multi-GB CUDA runtime packages.
RUN pip install --upgrade pip && \
pip install --index-url ${TORCH_INDEX_URL} ${TORCH_PACKAGE} && \
pip install -r requirements.txt && \
find /opt/venv -type d -name "__pycache__" -prune -exec rm -rf '{}' + && \
find /opt/venv -type f \( -name "*.pyc" -o -name "*.pyo" \) -delete
FROM node:20-alpine AS frontend-deps
WORKDIR /build/frontend
COPY frontend/package.json frontend/package-lock.json* ./
RUN if [ -f package-lock.json ]; then npm ci; else npm install; fi
FROM node:20-alpine AS frontend-builder
WORKDIR /build/frontend
ARG NEXT_PUBLIC_API_URL=/
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
COPY --from=frontend-deps /build/frontend/node_modules ./node_modules
COPY frontend/ ./
RUN npm run build
FROM node:20-bookworm-slim AS node-runtime
FROM python:3.10-slim AS runner
WORKDIR /app
ARG NEXT_PUBLIC_API_URL=/
ENV PATH="/opt/venv/bin:$PATH" \
NODE_ENV=production \
NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL} \
PORT=10113 \
HOSTNAME=0.0.0.0
RUN apt-get update && \
apt-get install -y --no-install-recommends bash ca-certificates && \
rm -rf /var/lib/apt/lists/*
COPY --from=node-runtime /usr/local/bin/node /usr/local/bin/node
COPY --from=backend-builder /opt/venv /opt/venv
COPY backend ./backend
COPY --from=frontend-builder /build/frontend/.next/standalone ./frontend
COPY --from=frontend-builder /build/frontend/.next/static ./frontend/.next/static
COPY --from=frontend-builder /build/frontend/public ./frontend/public
COPY start.sh ./start.sh
EXPOSE 10113
CMD ["/bin/bash", "/app/start.sh"]