-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathDockerfile
60 lines (42 loc) · 1.58 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
FROM python:3.8-slim-buster AS builder
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV PATH="/venv/bin:$PATH"
ENV LANG=C.UTF-8
RUN python -m venv /venv/
# Debian slim images needs the man directories created
# https://github.com/debuerreotype/debuerreotype/issues/10#issuecomment-438342078
RUN bash -c 'for i in {1..8}; do mkdir -p "/usr/share/man/man$i"; done' && \
apt-get update && \
apt-get install -y --no-install-recommends build-essential libxslt1.1 libxml2 libxml2-dev \
libxslt1-dev libpq-dev && \
rm -rf /var/lib/apt/lists/* /user/share/man
WORKDIR /app
COPY requirements.txt .
RUN pip install --require-hashes --no-cache-dir -r requirements.txt
COPY . /app
RUN DEBUG=False SECRET_KEY=foo ALLOWED_HOSTS=localhost,\
DATABASE_URL=sqlite:/// SITE_URL= \
./manage.py collectstatic --noinput
# Production image
FROM python:3.8-slim-buster
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV PATH="/venv/bin:$PATH"
ENV LANG=C.UTF-8
EXPOSE 8000
CMD ["./bin/run-prod.sh"]
RUN adduser --uid 1000 --disabled-password --gecos '' webdev
WORKDIR /app
RUN bash -c 'for i in {1..8}; do mkdir -p "/usr/share/man/man$i"; done' && \
apt-get update && \
apt-get install -y --no-install-recommends libpq-dev postgresql-client pngquant libxslt1.1 libxml2 && \
rm -rf /var/lib/apt/lists/* /usr/share/man
COPY --from=builder /venv /venv
COPY --from=builder /app /app
RUN chown webdev.webdev -R .
USER webdev
ARG GIT_SHA=head
ENV GIT_SHA=${GIT_SHA}