-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile
178 lines (161 loc) · 6.62 KB
/
Dockerfile
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#
# This Dockerfile defines a docker image for a docker container that you can run
# locally on your PC (provided that you have Docker for Windows or Docker for Mac
# running). It can also be deployed as a container in the ECS service of Amazon AWS.
#
# The functionality of the container is to run the whole publishing process or a part therof.
#
# You can build this image yourself by executing the following command in the same
# directory as where you found this Dockerfile:
#
# docker build .
#
# Using Alpine linux because it's ultra-lightweight, designed for running in a Docker
# container.
#
# - alpine is the name of the Linux brand we're using, which is the smallest linux keeping the image as small
# as possible.
#
FROM alpine:3.19
#
# Some meta data, can only have one maintainer unfortunately
#
LABEL maintainer="[email protected]"
LABEL owner="Enterprise Data Management Council"
#
# These ARG-variables are NOT necessarily environment variables that end up in the docker container itself. Unless
# their value is copied into a same named ENV variable. They're just there during the image build process itself.
# You can override their default values with any number of "--build-arg" options on the "docker build" command line.
#
ARG ONTPUB_FAMILY=fibo
ARG HYGIENE_TEST_PARAMETER_VALUE=edmcouncil
ARG ONTPUB_IS_DARK_MODE=1
ARG RDFTOOLKIT_VERSION
ARG CONSISTENCY_CHECK_TIMEOUT
ENV \
BASH_ENV=/etc/profile \
INPUT=/input \
OUTPUT=/output \
TMPDIR=/var/tmp
RUN install -dv -m0755 /publisher && install -dv -g 65534 -m0775 "${TMPDIR}" && \
ln -s /etc/bashrc /etc/profile.d/spec.sh
#
# Installing bash, curl, git, grep, coreutils
#
RUN \
echo ================================= install basics >&2 && \
apk --no-cache add \
bash curl git grep sed findutils coreutils tree jq yq bc xmlstarlet util-linux \
zip tar xz \
openjdk21 \
python3-dev py3-pip py3-wheel py3-cachetools py3-frozendict py3-isodate py3-lxml cython py3-pandas \
py3-pyld py3-rdflib py3-xlsxwriter \
libxml2-dev libxslt-dev \
perl fontconfig make \
gcc g++ linux-headers libc-dev && \
# "bash" preferable to "busybox"
ln -sf bash /bin/sh && \
ln -sf python3 /usr/bin/python && \
#
# Clean up
#
rm -rf /var/lib/apt/lists/*
#
# Installing Apache Jena
# INFRA-496 jena-arq-${JENA_VERSION}.jar: workaround to change default JSON-LD-10 output: JSONLD10 = JSONLD10_EXPAND_PRETTY instead of JSONLD10_COMPACT_PRETTY
#
ENV \
JENA_VERSION="4.10.0" \
JENA_HOME=/usr/share/java/jena/latest
RUN \
echo ================================= install jena ${JENA_VERSION} >&2 && \
name="apache-jena-${JENA_VERSION}" ; \
targz="${name}.tar.gz" ; \
url="http://archive.apache.org/dist/jena/binaries/${targz}" ; \
echo "Downloading ${url}:" >&2 ; \
curl -f --remote-time --location --silent --show-error --output /var/tmp/${targz} --url "${url}" && \
install -d "$(dirname "${JENA_HOME}")" && cd "$(dirname "${JENA_HOME}")" && \
tar xzpf /var/tmp/${targz} && \
rm -f /var/tmp/${targz} && \
mv ${name} ${JENA_VERSION} && \
ln -s ${JENA_VERSION} latest && \
sed -i 's#\\"##g' "${JENA_HOME}"/bin/{arq,riot} && \
cd ${JENA_HOME} && \
unzip lib-src/jena-arq-${JENA_VERSION}-sources.jar org/apache/jena/riot/RDFFormat.java && \
rm -rf src-examples lib-src bat && \
perl -pi -e 's/(\WJSONLD10\s+=\s+JSONLD(?:10)?_)(?:COMPACT_)?(PRETTY)/\1EXPAND_\2/g' org/apache/jena/riot/RDFFormat.java && \
javac -cp ${JENA_HOME}/lib/jena-arq-${JENA_VERSION}.jar org/apache/jena/riot/RDFFormat.java && \
zip -u ${JENA_HOME}/lib/jena-arq-${JENA_VERSION}.jar org/apache/jena/riot/RDFFormat.class && \
rm -rf org && \
version="$("${JENA_HOME}"/bin/arq --version | cut -d\ -f4)" && \
echo "installed version="[${version}]"" && \
test "${version}" == "${JENA_VERSION}"
#
# Installing [ROBOT](https://github.com/ontodev/robot)
#
ENV ROBOT_VERSION="v1.9.5"
RUN \
curl -f --remote-time --location --silent --show-error --output /usr/local/bin/robot https://raw.githubusercontent.com/ontodev/robot/${ROBOT_VERSION:-master}/bin/robot && \
curl -f --remote-time --location --silent --show-error --output /usr/local/bin/robot.jar https://github.com/ontodev/robot/releases/${ROBOT_VERSION:+download/}${ROBOT_VERSION:=latest/download}/robot.jar && \
chmod +x /usr/local/bin/robot
COPY etc /etc
COPY root /root
#
# Installing [rdf-toolkit](https://github.com/edmcouncil/rdf-toolkit)
#
# To force not the "latest" version, pass build-arg to the build process:
# docker build --build-arg RDFTOOLKIT_VERSION="<RDFTOOLKIT VERSION>"
# for example:
# docker build --build-arg RDFTOOLKIT_VERSION="v1.2"
# don't set RDFTOOLKIT_VERSION to use "latest" version
#
ENV RDFTOOLKIT_JAR=/usr/share/java/rdf-toolkit/rdf-toolkit.jar
RUN \
echo ================================= install the RDF toolkit >&2 && \
rdftoolkit_url="https://github.com/edmcouncil/rdf-toolkit/releases/${RDFTOOLKIT_VERSION:+download/}${RDFTOOLKIT_VERSION:=latest/download}/rdf-toolkit.jar" ; \
mkdir -p /usr/share/java/rdf-toolkit ; \
echo "Downloading ${rdftoolkit_url}:" >&2 ; \
curl -f --remote-time --location --silent --show-error --output ${RDFTOOLKIT_JAR} --url "${rdftoolkit_url}"
#
# Install OntoViewer Toolkit
#
ENV ONTOVIEWER_TOOLKIT_JAR=/usr/share/java/onto-viewer/onto-viewer-toolkit.jar
RUN \
echo "================================= install OntoViewer Toolkit" >&2 && \
url='https://jenkins.edmcouncil.org/view/onto-viewer/job/onto-viewer-publish/lastSuccessfulBuild/artifact/onto-viewer-toolkit/target/onto-viewer-toolkit.jar' ; \
mkdir -p /usr/share/java/onto-viewer ; \
echo "Downloading ${url}:" >&2 ; \
curl -f --remote-time --location --silent --show-error --output "${ONTOVIEWER_TOOLKIT_JAR}" --url "${url}"
#
# <skip in dev mode begin>
#
COPY /publisher /publisher
#
# Do some after-COPY "optimizations" to get rid of Windows CRLF's
#
RUN find /publisher/ -name '*.sh' | xargs sed -i 's/\r//'
#
# <skip in dev mode end>
#
#
# Your ontology repos are supposed to be under /input
#
#VOLUME ["${INPUT}" ]
#
# Mount your "target directory", the place where all published files end up, here
#
#VOLUME ["${OUTPUT}"]
#
# Mount a directory for temporary files
#
VOLUME ["${TMPDIR}"]
WORKDIR /publisher
RUN \
echo PATH=${PATH} && \
echo "export PATH=${PATH}" >> /etc/bashrc && \
sed -i "s/<ONTPUB_FAMILY>/${ONTPUB_FAMILY}/g ; s/<HYGIENE_TEST_PARAMETER_VALUE>/${HYGIENE_TEST_PARAMETER_VALUE}/g ; s/<ONTPUB_IS_DARK_MODE>/${ONTPUB_IS_DARK_MODE}/g" /etc/bashrc && \
ln -sf /var/tmp/.gitconfig /root/.gitconfig && \
ln -sf /var/tmp/.gitconfig /.gitconfig && \
rm -rvf /root/.cache
CMD ["./publish.sh"]