forked from mozilla-services/tecken
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
74 lines (56 loc) · 2.14 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
64
65
66
67
68
69
70
71
72
73
74
FROM node:6.14.4@sha256:08ee0b11474e62c62326321773b9d56c2e4b2ed309b7e2168428e2e34c90e8a7 as frontend
# these build args are turned into env vars
# and used in bin/build_frontend.sh
ARG FRONTEND_SENTRY_PUBLIC_DSN=UNSET_DSN
ENV FRONTEND_SENTRY_PUBLIC_DSN=${FRONTEND_SENTRY_PUBLIC_DSN}
ARG CI=false
ENV CI=${CI}
RUN echo "Running in CI: ${CI}"
COPY . /app
WORKDIR /app
RUN bin/build_frontend.sh
FROM python:3.6-slim@sha256:5a96684a1729acd0680b39a3c24ef33f36bb6951873f77cde1e227b059a0f881
ENV PYTHONUNBUFFERED=1 \
PYTHONPATH=/app/ \
DJANGO_CONFIGURATION=Prod \
PORT=8000
EXPOSE $PORT
# add a non-privileged user for installing and running the application
# don't use --create-home option to prevent populating with skeleton files
RUN mkdir /app && \
chown 10001:10001 /app && \
groupadd --gid 10001 app && \
useradd --no-create-home --uid 10001 --gid 10001 --home-dir /app app
# install a few essentials and clean apt caches afterwards
RUN apt-get update && \
apt-get install -y --no-install-recommends \
apt-transport-https build-essential curl git libpq-dev \
gettext libffi-dev jed
# Install dump_syms
RUN DEBIAN_FRONTEND=noninteractive \
apt-get install -y --no-install-recommends \
gyp ninja-build binutils-gold gcc-6 g++-6 pkg-config cabextract
COPY ./docker/build_dump_syms.sh /tmp
RUN /tmp/build_dump_syms.sh
# Clean up apt
RUN apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install Python dependencies
COPY requirements.txt /tmp/
COPY requirements-constraints.txt /tmp/
# Switch to /tmp to install dependencies outside home dir
WORKDIR /tmp
RUN pip install --no-cache-dir -r requirements.txt
COPY . /app
# Switch back to home directory
WORKDIR /app
# Copy static assets
COPY --from=frontend /app/frontend/build /app/frontend/build
RUN chown -R 10001:10001 /app
USER 10001
# Using /bin/bash as the entrypoint works around some volume mount issues on Windows
# where volume-mounted files do not have execute bits set.
# https://github.com/docker/compose/issues/2301#issuecomment-154450785 has additional background.
ENTRYPOINT ["/bin/bash", "/app/bin/run.sh"]
CMD ["web"]