-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
45 lines (31 loc) · 929 Bytes
/
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
########### BASE STAGE ###########
FROM python:3.10.8-alpine AS base
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# copy base requirements
COPY ./requirements.txt /app/
# install base dependencies
RUN apk add --no-cache --virtual .build-deps \
gcc \
musl-dev \
libxml2-dev \
libxslt-dev \
python3-dev \
&& apk add --no-cache py3-lxml mariadb-dev \
&& pip install --upgrade pip setuptools && pip install --no-cache-dir -r /app/requirements.txt \
&& apk del .build-deps
EXPOSE 8000
WORKDIR /app
########### DEV STAGE ###########
FROM base AS dev
########### PRODUCTION STAGE ###########
FROM base AS prod
# create a app user
RUN addgroup -S appuser && adduser -S appuser -G appuser
# create directory for collectstatic command
RUN mkdir /app/static_files
# copy project
COPY --chown=appuser:appuser ./app/ /app/
# change to the app user
USER appuser