-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
145 lines (103 loc) · 3.84 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
# Use alpine linux as base image
FROM eclipse-temurin:22-jdk-alpine AS builder
# Copy repository respecting .dockerignore
COPY . /kustvakt
WORKDIR /kustvakt
RUN apk update && \
apk add --no-cache git \
curl \
perl \
wget \
maven
RUN git config --global user.email "korap+docker@ids-mannheim.de" && \
git config --global user.name "Docker"
# Install Koral
RUN curl -I https://github.com/KorAP/Koral/releases/latest | \
grep location | \
perl -e '$|++; <> =~ m/tag\/(v[\d\.]+(?:-release)?)/; print "https://github.com/KorAP/Koral/archive/refs/tags/${1}\.zip\n"' |\
wget -i - && \
unzip *.zip && \
cd Koral-* && \
mvn clean install
RUN rm -r Koral-* v*.zip
RUN mkdir built
# Install Krill
RUN curl -I https://github.com/KorAP/Krill/releases/latest | \
grep location | \
perl -e '$|++; <> =~ m/tag\/(v[\d\.]+(?:-release)?)/; print "https://github.com/KorAP/Krill/archive/refs/tags/${1}\.zip\n"' |\
wget -i - && \
unzip *.zip && \
cd Krill-* && \
mvn clean install && \
mvn -Dmaven.test.skip=true package && \
mv target/Krill-Indexer.jar /kustvakt/built/Krill-Indexer.jar
RUN rm -r Krill-* v*.zip
# Package lite
RUN mvn clean package -P lite && \
find target/Kustvakt-lite-*.jar -exec mv {} /kustvakt/built/Kustvakt-lite.jar ';'
RUN sed 's!\(krill\.indexDir\s*=\).\+!\1\/kustvakt\/index!' src/main/resources/kustvakt-lite.conf \
> built/kustvakt-lite.conf
# Package full
RUN mvn clean package -DskipTests=true && \
find target/Kustvakt-full-*.jar -exec mv {} /kustvakt/built/Kustvakt-full.jar ';'
RUN cat src/main/resources/kustvakt.conf | \
sed 's!\(krill\.indexDir\s*=\).\+!\1\/kustvakt\/index!' | \
sed 's!\(ldap\.config\s*=\).\+!\1\/kustvakt\/ldap\/ldap\.conf!' | \
sed 's!\(oauth2\.initial\.super\.client\s*=\).\+!\1\/true!' | \
sed '$ a oauth2.initial.super.client = true' \
> built/kustvakt.conf
RUN sed 's!\(ldifFile\s*=\).\+!\1\/kustvakt\/ldap\/ldap.ldif!' \
src/main/resources/embedded-ldap-example.conf \
> built/ldap.conf
RUN cat src/main/resources/example-users.ldif \
> built/ldap.ldif
RUN apk del git \
perl \
curl \
wget \
maven
RUN cd ${M2_HOME} && rm -r .m2
# Cleanup
RUN rm -r src && \
rm -r wiki-index
FROM busybox:latest AS example-index
WORKDIR /kustvakt
RUN addgroup -S korap && \
adduser -S kustvakt -G korap && \
mkdir kustvakt && \
chown -R kustvakt.korap /kustvakt
COPY --from=builder /kustvakt/sample-index /kustvakt/index
USER kustvakt
CMD ["sh"]
FROM eclipse-temurin:22-jre-alpine AS kustvakt-lite
RUN addgroup -S korap && \
adduser -S kustvakt -G korap && \
mkdir kustvakt && \
chown -R kustvakt.korap /kustvakt
WORKDIR /kustvakt
COPY --from=builder /kustvakt/built/Kustvakt-lite.jar /kustvakt/
COPY --from=builder /kustvakt/built/kustvakt-lite.conf /kustvakt/
COPY --from=builder /kustvakt/built/Krill-Indexer.jar /kustvakt/
USER kustvakt
EXPOSE 8089
ENTRYPOINT [ "java", "-jar" ]
CMD [ "Kustvakt-lite.jar" ]
FROM eclipse-temurin:22-jre-alpine AS kustvakt-full
RUN addgroup -S korap && \
adduser -S kustvakt -G korap && \
mkdir kustvakt && \
chown -R kustvakt.korap /kustvakt
WORKDIR /kustvakt
RUN mkdir ./ldap \
mkdir ./client
COPY --from=builder /kustvakt/built/Kustvakt-full.jar /kustvakt/
COPY --from=builder /kustvakt/built/kustvakt.conf /kustvakt/
COPY --from=builder /kustvakt/built/ldap.* /kustvakt/ldap/
COPY --from=builder /kustvakt/built/Krill-Indexer.jar /kustvakt/
USER kustvakt
EXPOSE 8089
ENTRYPOINT [ "java", "-jar" ]
CMD [ "Kustvakt-full.jar" ]
# docker build -f Dockerfile -t korap/kustvakt:{nr}-full --target kustvakt-full .
# docker build -f Dockerfile -t korap/kustvakt:{nr} --target kustvakt-lite .
# docker build -f Dockerfile -t korap/example-index:{nr} --target example-index .