-
Notifications
You must be signed in to change notification settings - Fork 10
/
Dockerfile
59 lines (42 loc) · 1.33 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
########### BASE STAGE ###########
FROM python:3.7.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 py-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
# copy dev requirements
COPY ./requirements-dev.txt /app/
# install dev dependencies
RUN pip install --no-cache-dir -r /app/requirements-dev.txt
########### PRODUCTION STAGE ###########
FROM base AS prod
# copy crontab scripts
COPY ./conf/crontab/daily/* /etc/periodic/daily/
COPY ./conf/crontab/weekly/* /etc/periodic/weekly/
COPY ./conf/crontab/monthly/* /etc/periodic/monthly/
RUN chmod +x /etc/periodic/daily/*
RUN chmod +x /etc/periodic/weekly/*
RUN chmod +x /etc/periodic/monthly/*
# 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 ./bireme/ /app/
# change to the app user
USER appuser