-
Notifications
You must be signed in to change notification settings - Fork 30
/
Dockerfile
54 lines (36 loc) · 1.32 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
# First stage: build front app
FROM node:12.14-alpine AS node
WORKDIR /code
COPY ./frontend/package.json ./frontend/yarn.lock /code/
RUN yarn install --pure-lockfile --ignore-scripts
COPY ./frontend/ /code/
RUN yarn build
# Second stage: build base backend
FROM python:3.8-alpine AS backend
# Allow heroku exec
RUN apk add --no-cache curl postgresql-dev openssh bash
ADD ./.profile.d /app/.profile.d
ADD ./sh-wrapper.sh /bin/sh-wrapper.sh
COPY ./*.sh /code/
RUN chmod a+x /app/.profile.d/heroku-exec.sh && \
chmod a+x /bin/sh-wrapper.sh && \
chmod a+x /code/*.sh && \
rm /bin/sh && \
ln -s /bin/sh-wrapper.sh /bin/sh
ENV DJANGO_SETTINGS_MODULE root.settings.prod
ENV PYTHONPATH /code
ENV PIP_NO_CACHE_DIR true
RUN pip3 install --no-cache-dir pipenv gunicorn
WORKDIR /code
COPY ./backend/Pipfile* /code/
RUN apk add --no-cache --virtual build-dependencies gcc musl-dev python3-dev libffi-dev openssl-dev cargo curl-dev && \
pipenv install --system --deploy && \
apk del build-dependencies
RUN addgroup -S pythongroup && \
adduser -S pythonuser -G pythongroup --uid 2000 && \
chown -R pythonuser:pythongroup /code
USER pythonuser
COPY --from=node /code/build /code/front/static/front
COPY ./backend /code/
# Collect statics
RUN mkdir -p /code/static && SECRET_KEY=notused python ./manage.py collectstatic --no-input