-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
43 lines (26 loc) · 937 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
FROM python:3.9-alpine as builder
WORKDIR /usr/src/app
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
RUN apk update && apk add gcc python3-dev musl-dev postgresql-dev
# this line changes
COPY ./requirements.txt ./
RUN pip wheel --no-cache-dir --wheel-dir /usr/src/app/wheels -r requirements.txt
# === FINAL IMAGE ===
FROM python:3.9-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 --no-cache 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
CMD gunicorn project.wsgi:application --bind 0.0.0.0:8000