aboutsummaryrefslogtreecommitdiff
path: root/docker/Dockerfile
blob: dedd538b406db8acab7a4c0f2c0c0f6b1a48322c (plain)
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
####################
# Dependancy Builder
####################
FROM python:3.7-stretch AS builder

# Set working directory
WORKDIR /usr/src/app

# Turns off writing .pyc files; superfluous on an ephemeral container.
ENV PYTHONDONTWRITEBYTECODE=1
# Seems to speed things up
ENV PYTHONUNBUFFERED=1

# Use the executables from the virtualenv instead of globals
ENV PATH="/opt/venv/bin:$PATH"

# Setup virtualenv to build dependancies into
RUN python -m venv /opt/venv

# Install python dependancies
COPY requirements.txt ./requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

#####################
# Condensed App Image
#####################

# Smaller official Debian-based Python image
FROM python:3.7-slim-stretch AS app

# Set working directory
WORKDIR /usr/src/app

# Extra python env
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV PATH="/opt/venv/bin:$PATH"

# Setup the virtualenv
RUN python -m venv /opt/venv

# Copy in tools and python environment
COPY --from=builder /opt/venv /opt/venv

# Copy in the rest of the app
COPY ./ /usr/src/app