-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.prod
56 lines (39 loc) · 1.33 KB
/
Dockerfile.prod
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
####################
# 1 STAGE – PYTHON #
####################
FROM python:3.12-slim as python-builder
WORKDIR /code
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential libpq-dev curl && \
rm -rf /var/lib/apt/lists/*
COPY pyproject.toml poetry.lock ./
RUN pip install --upgrade pip && \
curl -sSL https://install.python-poetry.org | python3 - --version 1.7.1 && \
export PATH="/root/.local/bin:$PATH" && \
poetry config virtualenvs.create false && \
poetry install --without dev && \
playwright install firefox
##################
# 2 STAGE – NODE #
##################
FROM node:21.2-slim as node-builder
WORKDIR /code
COPY package*.json postcss.config.js tailwind.config.js ./
COPY static/css/ static/css/
COPY templates/ templates/
RUN npm install && npm run build
###################
# 3 STAGE – FINAL #
###################
FROM python:3.12-slim
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
APP_HOME=/code
WORKDIR $APP_HOME
RUN apt-get update && \
apt-get install -y --no-install-recommends libpq5 firefox-esr && \
rm -rf /var/lib/apt/lists/*
COPY --from=python-builder /usr/local/ /usr/local/
COPY --from=python-builder /root/.cache/ms-playwright /root/.cache/ms-playwright
COPY --from=node-builder $APP_HOME/static/css/ $APP_HOME/static/css/
COPY . .