-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile
60 lines (47 loc) · 1.34 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
########
# Python dependencies builder
#
FROM python:3-stretch AS builder
# Always set a working directory
WORKDIR /app
# Sets utf-8 encoding for Python
ENV LANG=C.UTF-8
# Turns off writing .pyc files. Superfluous on an ephemeral container.
ENV PYTHONDONTWRITEBYTECODE=1
# Seems to speed things up
ENV PYTHONUNBUFFERED=1
# Ensures that the python and pip executables used
# in the image will be those from our virtualenv.
ENV PATH="/venv/bin:$PATH"
# Install OS package dependencies.
# Do all of this in one RUN to limit final image size.
RUN apt-get update && \
apt-get install -y --no-install-recommends gettext build-essential && \
rm -rf /var/lib/apt/lists/*
# Setup the virtualenv
RUN python -m venv /venv
# Install Python deps
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
########
# slim app container
#
FROM python:3-slim-stretch AS app
# Extra python env
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV PATH="/venv/bin:$PATH"
ENV PORT=8000
# add non-priviledged user
RUN adduser --uid 1000 --disabled-password --gecos '' --no-create-home webdev
WORKDIR /app
EXPOSE 8000
CMD ["python", "app.py"]
# copy in Python environment
COPY --from=builder /venv /venv
COPY ./static ./static
COPY ./templates ./templates
COPY ./app.py ./
RUN chown webdev.webdev -R .
USER webdev