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
310LABEL maintainer="enviroDGI@gmail.com"
411
512RUN 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
827
928# Set the working directory to /app
1029WORKDIR /app
1130
31+ RUN pip install --upgrade pip
1232# Copy the requirements.txt alone into the container at /app
1333# so that they can be cached more aggressively than the rest of the source.
1434ADD requirements.txt /app
@@ -20,12 +40,22 @@ RUN pip install --trusted-host pypi.python.org -r requirements-experimental.txt
2040
2141# Copy the rest of the source.
2242ADD . /app
43+ # ...and install!
44+ RUN pip install .[server] --no-binary lxml
2345
24- # Install package.
25- RUN pip install .
2646
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
2957
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