1
- # Use an official Python runtime as a parent image
2
- FROM python:3.7-slim
1
+ # #
2
+ # `base` contains the only the core system-level dependencies needed to run
3
+ # the diff server. `dev` builds on it by adding compile-time support for the
4
+ # same packages so that we can build the Python dependencies that have C code,
5
+ # like `lxml`.
6
+ # We separate them out so that the final `release` image can layer on top of
7
+ # this one without needing compiler-related packages.
8
+ # #
9
+ FROM python:3.7-slim as base
3
10
LABEL maintainer=
"[email protected] "
4
11
5
12
RUN apt-get update && apt-get install -y --no-install-recommends \
6
- git gcc g++ pkg-config libxml2-dev libxslt-dev libz-dev \
7
- libssl-dev openssl libcurl4-openssl-dev
13
+ libxml2 libxslt1.1 libz1 openssl libcurl4
14
+
15
+
16
+ # #
17
+ # `dev` is an intermediate image that is used for building compiled
18
+ # dependencies or can be used as a development environment if you want to work
19
+ # in a Docker container.
20
+ # #
21
+ FROM base as dev
22
+
23
+ RUN apt-get update && apt-get install -y --no-install-recommends \
24
+ git gcc g++ pkg-config \
25
+ # Compiler-support for the system dependencies in `base`
26
+ libxml2-dev libxslt-dev libz-dev libssl-dev libcurl4-openssl-dev
8
27
9
28
# Set the working directory to /app
10
29
WORKDIR /app
11
30
31
+ RUN pip install --upgrade pip
12
32
# Copy the requirements.txt alone into the container at /app
13
33
# so that they can be cached more aggressively than the rest of the source.
14
34
ADD requirements.txt /app
@@ -20,12 +40,22 @@ RUN pip install --trusted-host pypi.python.org -r requirements-experimental.txt
20
40
21
41
# Copy the rest of the source.
22
42
ADD . /app
43
+ # ...and install!
44
+ RUN pip install .[server] --no-binary lxml
23
45
24
- # Install package.
25
- RUN pip install .
26
46
27
- # Make port 80 available to the world outside this container.
28
- EXPOSE 80
47
+ # #
48
+ # `release` is the final, release-ready image with only the necessary
49
+ # dependencies to run all diffs and the diff server.
50
+ # #
51
+ FROM base as release
52
+
53
+ # Copy built python dependencies.
54
+ COPY --from=dev /usr/local/lib/ /usr/local/lib/
55
+ # Copy executables.
56
+ COPY --from=dev /usr/local/bin /usr/local/bin
29
57
30
- # Run server on port 80 when the container launches.
31
- CMD ["web-monitoring-diff-server" , "80" ]
58
+ ENV LD_LIBRARY_PATH=/usr/local/lib
59
+
60
+ EXPOSE 80
61
+ CMD ["web-monitoring-diff-server" , "--port" , "80" ]
0 commit comments