-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathDockerfile
More file actions
84 lines (66 loc) · 2.62 KB
/
Copy pathDockerfile
File metadata and controls
84 lines (66 loc) · 2.62 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
##
# `base` contains only the core system-level dependencies needed to run
# the diff server. `dev` builds on it by adding compile-time support for the
# same packages so that we can build the Python dependencies that have C code,
# like `lxml`.
# We separate them out so that the final `release` image can layer on top of
# this one without needing compiler-related packages.
##
FROM python:3.10.20-slim AS base
RUN apt-get update && apt-get install -y --no-install-recommends \
libxml2 \
libxslt1.1 \
libz1 \
openssl \
libcurl4 \
&& rm -rf /var/lib/apt/lists/*
##
# `dev` is an intermediate image used for building compiled dependencies
# or as a development container.
##
FROM base AS dev
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
gcc \
g++ \
pkg-config \
# Compiler-support for the system dependencies in `base`
libxml2-dev \
libxslt-dev \
libz-dev \
libssl-dev \
libcurl4-openssl-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
RUN pip install --upgrade pip
RUN pip install cchardet
ADD pyproject.toml README.md requirements-experimental.txt /app/
# Create the folder where the version file needs to be written
RUN mkdir -p /app/web_monitoring_diff
# Set an environment variable to bypass the Git version check during dependency
# install. This dummy version (0.0.0) is temporary. The final install step later
# in this file will overwrite and correct the version number.
RUN SETUPTOOLS_SCM_PRETEND_VERSION=0.0.0 pip install ".[server]" --no-binary lxml
# Some experimental dependencies are not allowed as package extras, so we
# install via separate means.
RUN pip install --trusted-host pypi.python.org -r requirements-experimental.txt
# Copy the rest of the source.
ADD . /app
# ...and install!
RUN pip install ".[server]" --no-binary lxml
##
# `release` is the final production image.
##
FROM base AS release
LABEL org.opencontainers.image.title="web-monitoring-diff" \
org.opencontainers.image.description="Server for detecting changes in web content" \
org.opencontainers.image.authors="Environmental Data & Governance Initiative (EDGI)" \
org.opencontainers.image.url="https://envirodatagov.org/" \
org.opencontainers.image.source="https://github.com/edgi-govdata-archiving/web-monitoring-diff" \
org.opencontainers.image.documentation="https://web-monitoring-diff.readthedocs.io/" \
org.opencontainers.image.licenses="GPL-3.0-only"
COPY --from=dev /usr/local/lib/ /usr/local/lib/
COPY --from=dev /usr/local/bin/ /usr/local/bin/
ENV LD_LIBRARY_PATH=/usr/local/lib
EXPOSE 80
CMD ["web-monitoring-diff-server", "--port", "80"]