forked from mrlvsb/kelvin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
73 lines (51 loc) · 1.94 KB
/
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
FROM ghcr.io/astral-sh/uv:python3.12-bookworm AS build-backend
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
apt-get install -y \
-o APT::Install-Recommends=false \
-o APT::Install-Suggests=false \
libsasl2-dev \
libgraphviz-dev \
graphviz
WORKDIR /app
COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-dev --no-install-project --compile-bytecode
FROM node:22.9.0-bookworm-slim AS build-frontend
WORKDIR /frontend
COPY frontend .
RUN mkdir -p /web/static
RUN npm ci
RUN npm run build
FROM python:3.12-bookworm AS runtime
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
apt-get install -y \
-o APT::Install-Recommends=false \
-o APT::Install-Suggests=false \
graphviz && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
WORKDIR /app
# Create new user to run app process as unprivilaged user
RUN groupadd --gid 102 webserver && \
useradd --uid 101 --gid 102 --shell /bin/false --system webserver
RUN chown -R webserver:webserver /app
COPY --from=build-backend --chown=webserver:webserver /app .
ENV PATH="/app/.venv/bin:$PATH"
COPY --chown=webserver:webserver web ./web
COPY --from=build-frontend --chown=uvicorn:uvicorn /web/static/frontend.* ./web/static/
COPY --from=build-frontend --chown=uvicorn:uvicorn /web/static/dolos ./web/static/dolos
COPY --chown=webserver:webserver kelvin ./kelvin
COPY --chown=webserver:webserver templates ./templates
COPY --chown=webserver:webserver evaluator ./evaluator
COPY --chown=webserver:webserver survey ./survey
COPY --chown=webserver:webserver common ./common
COPY --chown=webserver:webserver api ./api
COPY --chown=webserver:webserver manage.py .
RUN mkdir -p /socket && chown webserver:webserver /socket
USER webserver
RUN python manage.py collectstatic --no-input --clear
EXPOSE 8000
COPY --chown=webserver:webserver deploy/entrypoint.sh ./
ENTRYPOINT [ "/app/entrypoint.sh" ]
STOPSIGNAL SIGINT