-
Notifications
You must be signed in to change notification settings - Fork 43
/
app.Dockerfile
50 lines (32 loc) · 1.19 KB
/
app.Dockerfile
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
# Frontend
FROM node:20-alpine3.18 as frontend
WORKDIR /usr/src/app
COPY ./frontend ./frontend
WORKDIR /usr/src/app/frontend
RUN npm install && npm run build && rm -rf node_modules
# Backend
FROM python:3.11-slim-bookworm as backend
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential libmagic-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY pyproject.toml poetry.lock ./
RUN poetry config virtualenvs.create false \
&& poetry install --without dev
# Main
FROM python:3.11-slim-bookworm
COPY --from=backend /usr/local/lib/python3.11/site-packages/ /usr/local/lib/python3.11/site-packages/
COPY --from=backend /usr/local/bin/ /usr/local/bin/
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential libmagic-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/app
ARG USERNAME=nobody
USER $USERNAME
COPY --chown=$USERNAME gunicorn.conf.py ./
COPY --chown=$USERNAME backend ./backend
COPY --chown=$USERNAME --from=frontend /usr/src/app/frontend ./frontend
CMD ["gunicorn", "-k", "uvicorn.workers.UvicornWorker", "backend.main:app"]