-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathDockerfile
49 lines (28 loc) · 967 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
46
47
48
49
FROM python:3.7-alpine as builder
WORKDIR /usr/src/app
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
RUN apk update && apk add gcc python3-dev musl-dev
COPY ./Pipfile* ./
RUN pip install pipenv
RUN pipenv lock --requirements > ./requirements.txt
RUN pip wheel --no-cache-dir --wheel-dir /usr/src/app/wheels -r requirements.txt
# === FINAL IMAGE ===
FROM python:3.7-alpine
RUN addgroup -S app && adduser -S app -G app
# Create directories app_home and static directories
ENV HOME=/home/app
ENV APP_HOME=/home/app/web
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
# Copy dependencies from builder image
RUN apk update && apk add libpq
COPY --from=builder /usr/src/app/wheels /wheels
COPY --from=builder /usr/src/app/requirements.txt .
RUN pip install --no-cache --no-deps /wheels/*
COPY . $APP_HOME
RUN chown -R app:app $APP_HOME
USER app
RUN python manage.py collectstatic --noinput
RUN python manage.py migrate
CMD python manage.py runserver 8000