Skip to content

Commit eac9f0c

Browse files
authored
Merge pull request #16 from TEIC/dev
0.6.0
2 parents 74ccc0e + feaa2ea commit eac9f0c

12 files changed

Lines changed: 454 additions & 182 deletions

File tree

.github/workflows/docker.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/maven.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/maven_docker.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# This workflow will build a Java project with Maven
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3+
4+
name: maven and docker
5+
on:
6+
push:
7+
branches: [ main, dev ]
8+
tags: [ v* ]
9+
pull_request:
10+
branches: [ main, dev ]
11+
jobs:
12+
build:
13+
name: compile maven package
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Set up JDK 11
19+
uses: actions/setup-java@v2
20+
with:
21+
java-version: '11'
22+
distribution: 'adopt'
23+
- name: maven-settings
24+
uses: s4u/maven-settings-action@v2
25+
with:
26+
servers: '[{"id": "edirom", "username": "${github.actor}", "password": "${GITHUB_TOKEN}"},{"id": "teic", "username": "${github.actor}", "password": "${GITHUB_TOKEN}"}]'
27+
- name: Build with Maven
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
run: mvn clean package --file pom.xml
31+
- name: Upload Maven build artifact
32+
uses: actions/upload-artifact@v2
33+
with:
34+
name: artifact
35+
path: /home/runner/work/TEIGarage/TEIGarage/target/teigarage.war
36+
docker:
37+
name: build the Docker image
38+
needs: build
39+
runs-on: ubuntu-latest
40+
#don't run docker build on pull request at all
41+
if: ${{ github.event_name != 'pull_request' }}
42+
steps:
43+
- name: Checkout repository
44+
uses: actions/checkout@v2
45+
46+
- name: Download artifact
47+
uses: actions/download-artifact@v3
48+
with:
49+
name: artifact
50+
path: artifact/
51+
52+
- name: Display structure of downloaded files
53+
run: ls -R
54+
working-directory: artifact
55+
56+
# use the current user to log into the
57+
# GitHub container registry
58+
- name: Log in to GitHub Container registry
59+
uses: docker/login-action@v1
60+
with:
61+
registry: ghcr.io
62+
username: ${{ github.actor }}
63+
password: ${{ secrets.GITHUB_TOKEN }}
64+
65+
# Login against DockerHub registry
66+
- name: Log in to DockerHub
67+
uses: docker/login-action@v1
68+
with:
69+
username: ${{ secrets.PETERS_DOCKERHUB_USERNAME }}
70+
password: ${{ secrets.PETERS_DOCKERHUB_TOKEN }}
71+
72+
# Extract metadata (tags, labels) for Docker
73+
# https://github.com/docker/metadata-action
74+
- name: Extract Docker metadata
75+
id: meta
76+
uses: docker/metadata-action@v3
77+
with:
78+
images: |
79+
ghcr.io/teic/teigarage
80+
teic/teigarage
81+
flavor: |
82+
latest=${{ github.ref == 'refs/heads/main' }}
83+
84+
# Build and push Docker image with Buildx (don't push on PR)
85+
# https://github.com/docker/build-push-action
86+
- name: Build and push Docker image
87+
uses: docker/build-push-action@v2
88+
with:
89+
context: .
90+
push: ${{ github.event_name != 'pull_request' }}
91+
tags: ${{ steps.meta.outputs.tags }}
92+
labels: ${{ steps.meta.outputs.labels }}
93+
build-args: |
94+
BUILDTYPE=github

Dockerfile

Lines changed: 52 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,25 @@
55
# of both the ege-webclient and the TEIGarage (backend),
66
# and installs it in a Tomcat application server
77
#########################################
8-
FROM tomcat:7
8+
FROM tomcat:9-jdk11-openjdk
99

1010
LABEL org.opencontainers.image.source=https://github.com/teic/teigarage
1111

12+
ARG VERSION_STYLESHEET=latest
13+
ARG VERSION_ODD=latest
14+
ARG WEBSERVICE_ARTIFACT=https://nightly.link/TEIC/TEIGarage/workflows/maven_docker/dev/artifact.zip
15+
ARG WEBCLIENT_ARTIFACT=https://nightly.link/TEIC/ege-webclient/workflows/maven/main/artifact.zip
16+
ARG BUILDTYPE=local
17+
1218
ENV CATALINA_WEBAPPS ${CATALINA_HOME}/webapps
1319
ENV OFFICE_HOME /usr/lib/libreoffice
14-
ENV STYLESHEETS_HOME /usr/share/xml/tei
20+
ENV TEI_SOURCES_HOME /usr/share/xml/tei
1521

1622
USER root:root
1723

1824
RUN apt-get update \
19-
&& apt-get install -y libreoffice \
20-
ttf-dejavu \
25+
&& apt-get install --no-install-recommends -y libreoffice \
26+
fonts-dejavu \
2127
fonts-arphic-ukai \
2228
fonts-arphic-uming \
2329
fonts-baekmuk \
@@ -27,23 +33,18 @@ RUN apt-get update \
2733
fonts-ipafont-mincho \
2834
cmake \
2935
build-essential \
30-
libgcc-8-dev \
36+
libgcc-10-dev \
3137
librsvg2-bin \
38+
curl \
3239
&& ln -s ${OFFICE_HOME} /usr/lib/openoffice \
33-
&& rm -rf /var/lib/apt/lists/* \
34-
&& mkdir -p ${STYLESHEETS_HOME}
40+
&& rm -rf /var/lib/apt/lists/*
3541

3642
# entrypoint script
3743
COPY docker-entrypoint.sh /my-docker-entrypoint.sh
3844

3945
# log4j.xml configuration
4046
COPY log4j.xml /var/cache/oxgarage/log4j.xml
4147

42-
# download artifacts to /tmp
43-
# these war-files are zipped so we need to unzip them twice at the next stage
44-
ADD https://nightly.link/TEIC/TEIGarage/workflows/maven/main/artifact.zip /tmp/teigarage.zip
45-
ADD https://nightly.link/TEIC/ege-webclient/workflows/maven/main/artifact.zip /tmp/webservice.zip
46-
4748
# we could download the artifacts directly from GitHub but then
4849
# we would need to pass in secrets since the GitHub API does not allow
4950
# anonyous access. The following code is only for reference:
@@ -53,24 +54,50 @@ ADD https://nightly.link/TEIC/ege-webclient/workflows/maven/main/artifact.zip /t
5354
# && unzip /tmp/teigarage.zip -d /tmp/ \
5455
# && unzip /tmp/webservice.zip -d /tmp/
5556

56-
# download TEI resources to /tmp
57-
ADD https://github.com/TEIC/Stylesheets/releases/download/v7.52.0/tei-xsl-7.52.0.zip /tmp/stylesheet.zip
58-
ADD https://github.com/TEIC/TEI/releases/download/P5_Release_4.3.0/tei-4.3.0.zip /tmp/odd.zip
57+
# download artifacts to /tmp and deploy them at ${CATALINA_WEBAPPS}
58+
# these war-files are zipped so we need to unzip them twice
59+
#conditional copy in docker needs a strange hack
60+
COPY log4j.xml artifact/teigarage.wa[r] /tmp/
5961

60-
# unzip TEI resources and move them to correct folder
61-
RUN unzip -q /tmp/stylesheet.zip -d ${STYLESHEETS_HOME}/stylesheet \
62-
&& unzip -q /tmp/odd.zip -d ${STYLESHEETS_HOME}/odd
63-
64-
RUN rm -Rf ${CATALINA_WEBAPPS}/ROOT \
65-
&& unzip -q /tmp/webservice.zip -d /tmp/ \
66-
&& unzip -q /tmp/teigarage.zip -d /tmp/ \
67-
&& unzip -q /tmp/ege-webclient.war -d ${CATALINA_WEBAPPS}/ROOT/ \
62+
RUN if [ "$BUILDTYPE" = "local" ] ; then \
63+
curl -Ls ${WEBSERVICE_ARTIFACT} -o /tmp/teigarage.zip \
64+
&& unzip -o -q /tmp/teigarage.zip -d /tmp/; \
65+
fi \
6866
&& unzip -q /tmp/teigarage.war -d ${CATALINA_WEBAPPS}/ege-webservice/ \
67+
&& rm -Rf ${CATALINA_WEBAPPS}/ROOT \
68+
&& curl -Ls ${WEBCLIENT_ARTIFACT} -o /tmp/webclient.zip \
69+
&& unzip -q /tmp/webclient.zip -d /tmp/ \
70+
&& unzip -q /tmp/ege-webclient.war -d ${CATALINA_WEBAPPS}/ROOT/ \
6971
&& cp ${CATALINA_WEBAPPS}/ege-webservice/WEB-INF/lib/oxgarage.properties /etc/ \
70-
&& rm /tmp/*.war \
71-
&& rm /tmp/*.zip \
72+
&& rm -f /tmp/*.war \
73+
&& rm -f /tmp/*.zip \
7274
&& chmod 755 /my-docker-entrypoint.sh
7375

76+
#check if the version of stylesheet version is supplied, if not find out latest version
77+
RUN if [ "$VERSION_STYLESHEET" = "latest" ] ; then \
78+
VERSION_STYLESHEET=$(curl "https://api.github.com/repos/TEIC/Stylesheets/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")'); \
79+
fi \
80+
&& echo "Stylesheet version set to ${VERSION_STYLESHEET}" \
81+
# download the required tei odd and stylesheet sources in the image and move them to the respective folders (${TEI_SOURCES_HOME})
82+
&& curl -s -L -o /tmp/stylesheet.zip https://github.com/TEIC/Stylesheets/releases/download/v${VERSION_STYLESHEET}/tei-xsl-${VERSION_STYLESHEET}.zip \
83+
&& unzip /tmp/stylesheet.zip -d /tmp/stylesheet \
84+
&& rm /tmp/stylesheet.zip \
85+
&& mkdir -p ${TEI_SOURCES_HOME}/stylesheet \
86+
&& cp -r /tmp/stylesheet/xml/tei/stylesheet/* ${TEI_SOURCES_HOME}/stylesheet \
87+
&& rm -r /tmp/stylesheet
88+
89+
RUN if [ "$VERSION_ODD" = "latest" ] ; then \
90+
VERSION_ODD=$(curl "https://api.github.com/repos/TEIC/TEI/releases/latest" | grep -Po '"tag_name": "P5_Release_\K.*?(?=")'); \
91+
fi \
92+
&& echo "ODD version set to ${VERSION_ODD}" \
93+
# download the required tei odd and stylesheet sources in the image and move them to the respective folders ( ${TEI_SOURCES_HOME})
94+
&& curl -s -L -o /tmp/odd.zip https://github.com/TEIC/TEI/releases/download/P5_Release_${VERSION_ODD}/tei-${VERSION_ODD}.zip \
95+
&& unzip /tmp/odd.zip -d /tmp/odd \
96+
&& rm /tmp/odd.zip \
97+
&& mkdir -p ${TEI_SOURCES_HOME}/odd \
98+
&& cp -r /tmp/odd/xml/tei/odd/* ${TEI_SOURCES_HOME}/odd \
99+
&& rm -r /tmp/odd
100+
74101
VOLUME ["/usr/share/xml/tei/stylesheet", "/usr/share/xml/tei/odd"]
75102

76103
EXPOSE 8080 8081

0 commit comments

Comments
 (0)