-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
35 lines (29 loc) · 1.29 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
FROM python:3.8-alpine3.12
ARG PIP_CMD="pip install"
# Copy the files needed to build the app
WORKDIR /var/www/woolgatherer
COPY setup.py alembic.ini ./
COPY src src
COPY sql sql
COPY alembic alembic
COPY scripts scripts
COPY static static
COPY templates templates
# Install build dependencies, then install app, then remove build dependencies
# and install the libpq dependency for postgresql
RUN apk add --no-cache libpq py3-scipy \
&& apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev libffi-dev cargo make \
&& $PIP_CMD install -U pip && $PIP_CMD .[postgresql,redis] && apk del .build-deps \
&& rm -rf setup.py alembic.ini src alembic scripts \
&& mkdir -p /usr/local/share/woolgatherer \
&& ln -s /usr/local/share/woolgatherer/alembic.ini . \
&& ln -s /usr/local/share/woolgatherer/alembic .
# Scipy is installed to the system python, so include it in the python path
ENV PYTHONPATH=/usr/lib/python3.8/site-packages
# Create a user and group that actually run the app, so we aren't running as root
RUN addgroup -S gw && mkdir /home/gw && adduser -S gw -G gw -h /home/gw \
&& chown -R gw:gw /usr/local/share/woolgatherer \
&& chown gw:gw /home/gw && chown -R gw:gw .
# Tell docker that all future commands should run as the gw user
USER gw
CMD gw