-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
67 lines (46 loc) · 1.5 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
FROM node:22-bullseye as node_builder
WORKDIR /app
COPY . .
RUN npm install --omit=dev
# The builder image, used to build the virtual environment
FROM python:3.11-buster as builder
WORKDIR /app
COPY --from=node_builder /app .
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# Install poetry via pip
RUN pip install poetry==1.7.1
ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache
# Update and install dependencies for compiling .po files
RUN apt-get update && \
apt-get install -y make gettext
COPY pyproject.toml poetry.lock Makefile ./
COPY lib ./lib
COPY locale ./
RUN poetry install --without dev --no-root && rm -rf $POETRY_CACHE_DIR
RUN make compile_messages
# The runtime image, used to just run the code provided its virtual environment
FROM python:3.11-slim-buster as runtime
# Update and Install Netcat
RUN apt-get update && \
apt-get install -y netcat
WORKDIR /app
ENV VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:$PATH"
# copy project and dependencies
COPY . .
COPY --from=builder /app/static ./static
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
RUN chmod +x ./scripts/app-entrypoint.sh
RUN python manage.py collectstatic --noinput
# Use a non-root user
RUN addgroup --gid 31337 --system appuser \
&& adduser --uid 31337 --system appuser --ingroup appuser
RUN chown --recursive appuser:appuser /app
USER 31337
EXPOSE 8000
ENTRYPOINT [ "./scripts/app-entrypoint.sh" ]