-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
117 lines (98 loc) · 5.35 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
#########################################
# Dockerfile for setting up the TEIGarage.
# This installs dependencies to the system,
# then downloads the latest artifacts
# of both the ege-webclient and the TEIGarage (backend),
# and installs it in a Tomcat application server
#########################################
FROM tomcat:9-jdk11
LABEL org.opencontainers.image.source=https://github.com/teic/teigarage
ARG VERSION_STYLESHEET=latest
ARG VERSION_ODD=latest
ARG WEBSERVICE_ARTIFACT=https://nightly.link/TEIC/TEIGarage/workflows/maven_docker/dev/artifact.zip
ARG WEBCLIENT_ARTIFACT=https://nightly.link/TEIC/ege-webclient/workflows/maven/main/artifact.zip
ARG BUILDTYPE=local
ENV CATALINA_WEBAPPS ${CATALINA_HOME}/webapps
ENV OFFICE_HOME /usr/lib/libreoffice
ENV TEI_SOURCES_HOME /usr/share/xml/tei
USER root:root
RUN apt-get update \
&& apt-get install --no-install-recommends -y libreoffice \
fonts-dejavu \
fonts-arphic-ukai \
fonts-arphic-uming \
fonts-baekmuk \
fonts-junicode \
fonts-linuxlibertine \
fonts-ipafont-gothic \
fonts-ipafont-mincho \
cmake \
build-essential \
libgcc-10-dev \
librsvg2-bin \
curl \
unzip \
&& ln -s ${OFFICE_HOME} /usr/lib/openoffice \
&& rm -rf /var/lib/apt/lists/*
# entrypoint script
COPY docker-entrypoint.sh /my-docker-entrypoint.sh
# log4j.xml configuration
COPY log4j.xml /var/cache/oxgarage/log4j.xml
# we could download the artifacts directly from GitHub but then
# we would need to pass in secrets since the GitHub API does not allow
# anonyous access. The following code is only for reference:
#RUN --mount=type=secret,id=GITHUB_USER --mount=type=secret,id=GITHUB_TOKEN \
# curl -u $(cat /run/secrets/GITHUB_USER):$(cat /run/secrets/GITHUB_TOKEN) -Ls $(curl -u $(cat /run/secrets/GITHUB_USER):$(cat /run/secrets/GITHUB_TOKEN) -Ls -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/TEIC/TEIGarage/actions/artifacts | jq -r ".artifacts[0].archive_download_url") -o /tmp/teigarage.zip \
# && curl -u $(cat /run/secrets/GITHUB_USER):$(cat /run/secrets/GITHUB_TOKEN) -Ls $(curl -u $(cat /run/secrets/GITHUB_USER):$(cat /run/secrets/GITHUB_TOKEN) -Ls -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/TEIC/ege-webclient/actions/artifacts | jq -r ".artifacts[0].archive_download_url") -o /tmp/webservice.zip \
# && unzip /tmp/teigarage.zip -d /tmp/ \
# && unzip /tmp/webservice.zip -d /tmp/
# download artifacts to /tmp and deploy them at ${CATALINA_WEBAPPS}
# if the action is run on github, the war is already located in the artifact folder because of the previous github action
#RUN if [ "$BUILDTYPE" = "github" ] ; then \
# cp artifact/teigarage.war /tmp/ ; \
# fi
COPY artifac[t]/teigarage.wa[r] /tmp/
# if docker build is local the latest artifact needs to be downloaded using the nightly link url
RUN if [ "$BUILDTYPE" = "local" ] ; then \
curl -Ls ${WEBSERVICE_ARTIFACT} -o /tmp/teigarage.zip \
&& unzip -o -q /tmp/teigarage.zip -d /tmp/; \
fi
# these war-files are zipped so we need to unzip them twice
# the GUI/webclient needs to be downloaded locally and on github
RUN unzip -q /tmp/teigarage.war -d ${CATALINA_WEBAPPS}/ege-webservice/ \
&& rm -Rf ${CATALINA_WEBAPPS}/ROOT \
&& curl -Ls ${WEBCLIENT_ARTIFACT} -o /tmp/webclient.zip \
&& unzip -q /tmp/webclient.zip -d /tmp/ \
&& unzip -q /tmp/ege-webclient.war -d ${CATALINA_WEBAPPS}/ROOT/ \
&& cp ${CATALINA_WEBAPPS}/ege-webservice/WEB-INF/lib/oxgarage.properties /etc/ \
&& rm -f /tmp/*.war \
&& rm -f /tmp/*.zip \
&& chmod 755 /my-docker-entrypoint.sh
#check if the version of stylesheet version is supplied, if not find out latest version
RUN if [ "$VERSION_STYLESHEET" = "latest" ] ; then \
VERSION_STYLESHEET=$(curl "https://api.github.com/repos/TEIC/Stylesheets/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")'); \
fi \
&& echo "Stylesheet version set to ${VERSION_STYLESHEET}" \
# download the required tei odd and stylesheet sources in the image and move them to the respective folders (${TEI_SOURCES_HOME})
&& curl -s -L -o /tmp/stylesheet.zip https://github.com/TEIC/Stylesheets/releases/download/v${VERSION_STYLESHEET}/tei-xsl-${VERSION_STYLESHEET}.zip \
&& unzip /tmp/stylesheet.zip -d /tmp/stylesheet \
&& rm /tmp/stylesheet.zip \
&& mkdir -p ${TEI_SOURCES_HOME}/stylesheet \
&& cp -r /tmp/stylesheet/xml/tei/stylesheet/* ${TEI_SOURCES_HOME}/stylesheet \
&& rm -r /tmp/stylesheet
RUN if [ "$VERSION_ODD" = "latest" ] ; then \
VERSION_ODD=$(curl "https://api.github.com/repos/TEIC/TEI/releases/latest" | grep -Po '"tag_name": "P5_Release_\K.*?(?=")'); \
fi \
&& echo "ODD version set to ${VERSION_ODD}" \
# download the required tei odd and stylesheet sources in the image and move them to the respective folders ( ${TEI_SOURCES_HOME})
&& curl -s -L -o /tmp/odd.zip https://github.com/TEIC/TEI/releases/download/P5_Release_${VERSION_ODD}/tei-${VERSION_ODD}.zip \
&& unzip /tmp/odd.zip -d /tmp/odd \
&& rm /tmp/odd.zip \
&& mkdir -p ${TEI_SOURCES_HOME}/odd \
&& cp -r /tmp/odd/xml/tei/odd/* ${TEI_SOURCES_HOME}/odd \
&& rm -r /tmp/odd
VOLUME ["/usr/share/xml/tei/stylesheet", "/usr/share/xml/tei/odd"]
EXPOSE 8080 8081
HEALTHCHECK CMD curl --fail http://localhost:8080/ege-webservice/Info || exit 1
ENTRYPOINT ["/my-docker-entrypoint.sh"]
CMD ["catalina.sh", "run"]