-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDockerfile
63 lines (45 loc) · 1.48 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
60
61
62
63
###########
# BUILDER #
###########
# pull official base image
FROM python:3.9.9-slim as builder
# set work directory
WORKDIR /app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# install system dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends gcc \
python3-psycopg2 apache2 apache2-dev
# install python dependencies
RUN pip install --upgrade pip ; \
pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels mod_wsgi newrelic
COPY requirements.txt .
COPY requirements_dev.txt .
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt
#########
# FINAL #
#########
# pull official base image
FROM python:3.9.9-slim
# install psycopg2 dependencies
RUN apt-get update && apt-get install -y python3-psycopg2 \
apache2 poppler-utils && rm -rf /var/lib/apt/lists/*
RUN addgroup --system app && useradd --system --create-home --gid app --shell /bin/false app
# create the appropriate directories
ENV APP_HOME=/code
RUN mkdir $APP_HOME $APP_HOME/static && chown app:app -R $APP_HOME
WORKDIR $APP_HOME
ENV PATH="/home/app/.local/bin:${PATH}"
# change to the app user
USER app
# install dependencies
COPY --chown=app:app --from=builder /usr/src/app/wheels /wheels
COPY --chown=app:app --from=builder /app/requirements.txt .
RUN pip install --upgrade pip ; \
pip install --no-cache /wheels/*
# copy project
COPY --chown=app:app . $APP_HOME
EXPOSE 8080
CMD ["/code/start.sh"]