Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
90 lines (77 loc) · 3.85 KB
/
Copy pathDockerfile
File metadata and controls
90 lines (77 loc) · 3.85 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
85
86
87
88
89
90
ARG REGISTRY=docker.io
ARG UBUNTU_IMAGE_VERSION=26.04
ARG OPENJDK_VERSION=25
#----------------------------------------------------------------------
# Build stage - validator-cli.jar
#----------------------------------------------------------------------
FROM ${REGISTRY}/library/ubuntu:${UBUNTU_IMAGE_VERSION} AS builder
ARG OPENJDK_VERSION
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -qq \
&& apt-get install --no-install-recommends -y \
ca-certificates maven gdal-bin openjdk-${OPENJDK_VERSION}-jdk-headless \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/validator
COPY pom.xml .
COPY validator-cli/ validator-cli/
COPY validator-core/ validator-core/
COPY validator-plugin-cnig/ validator-plugin-cnig/
COPY validator-plugin-dgpr/ validator-plugin-dgpr/
COPY validator-plugin-pcrs/ validator-plugin-pcrs/
# Behind a proxy : --build-arg https_proxy=http://proxy:3128 (or "proxies" in ~/.docker/config.json, see doc/docker.md).
# The predefined proxy build args (http_proxy, https_proxy, no_proxy) are used by apt and converted
# to java system properties for maven (maven ignores these environment variables).
ARG MAVEN_OPTS="-DskipTests"
RUN set -f; \
proxy="${https_proxy:-${HTTPS_PROXY:-${http_proxy:-${HTTP_PROXY:-}}}}"; \
PROXY_OPTS=""; \
if [ -n "$proxy" ]; then \
hostport="${proxy#*://}"; hostport="${hostport#*@}"; hostport="${hostport%%/*}"; \
host="${hostport%:*}"; port="${hostport##*:}"; \
if [ "$port" = "$hostport" ]; then port=80; fi; \
PROXY_OPTS="-Dhttp.proxyHost=$host -Dhttp.proxyPort=$port -Dhttps.proxyHost=$host -Dhttps.proxyPort=$port"; \
nonproxy="$(echo "${no_proxy:-${NO_PROXY:-}}" | tr ',' '|')"; \
if [ -n "$nonproxy" ]; then PROXY_OPTS="$PROXY_OPTS -Dhttp.nonProxyHosts=$nonproxy"; fi; \
echo "maven proxy : $PROXY_OPTS"; \
fi; \
mvn clean package ${MAVEN_OPTS} ${PROXY_OPTS}
#----------------------------------------------------------------------
# Runtime stage
#----------------------------------------------------------------------
FROM ${REGISTRY}/library/ubuntu:${UBUNTU_IMAGE_VERSION}
ARG OPENJDK_VERSION
LABEL description="validator-cli - validate and normalize datasets according to a document model." \
org.opencontainers.image.source="https://github.com/IGNF/validator"
# JAVA_TOOL_OPTIONS : in a container the JVM only uses 25 % of the available memory by default
# (an explicit -Xmx, ex: -Xmx2g, takes precedence). Override with `-e JAVA_TOOL_OPTIONS=...`.
# The French locale (as in IGNF/validator-api) is used by the JVM to translate
# XML validation messages (PCRS). Override with `-e LANG=C.UTF-8 -e LC_ALL=C.UTF-8` for english messages.
ENV DEBIAN_FRONTEND=noninteractive \
LANG=fr_FR.UTF-8 LC_ALL=fr_FR.UTF-8 LANGUAGE=fr_FR.UTF-8 \
TZ=Europe/Paris \
VALIDATOR_PATH=/opt/validator/validator-cli.jar \
GMLAS_CONFIG=/opt/validator/gmlasconf-validator.xml \
JAVA_TOOL_OPTIONS=-XX:MaxRAMPercentage=75
# locale, trust store, java and ogr2ogr (required by validator-cli.jar)
RUN apt-get update -qq \
&& apt-get install --no-install-recommends -y \
locales ca-certificates openjdk-${OPENJDK_VERSION}-jre-headless gdal-bin \
&& echo "fr_FR.UTF-8 UTF-8" > /etc/locale.gen \
&& locale-gen fr_FR.UTF-8 \
&& update-locale LANG=fr_FR.UTF-8 LC_ALL=fr_FR.UTF-8 \
&& update-ca-certificates \
&& java -version \
&& ogrinfo --version \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /opt/validator
COPY --from=builder /usr/src/validator/validator-cli/target/validator-cli.jar ${VALIDATOR_PATH}
# adapted configuration for the GMLAS driver
COPY validator-core/src/main/resources/gdal/gmlasconf-validator.xml ${GMLAS_CONFIG}
# Security : run as non-root user (ubuntu, uid=1000), ogr2ogr needs to write in $HOME/.gdal
ENV HOME=/home/ubuntu
USER ubuntu
WORKDIR /data
ENTRYPOINT ["java", "-jar", "/opt/validator/validator-cli.jar"]
CMD ["--help"]