blob: 7b2d1d19fe1c1cc953340dc01b708be0e225da10 [file] [log] [blame]
Akronf09fc562023-01-11 08:47:21 +01001# Build stage
2FROM golang:latest as build
Akron23711ef2024-03-15 11:26:28 +01003
4RUN apt-get update && \
5 apt-get upgrade -y ca-certificates
6
Akronf09fc562023-01-11 08:47:21 +01007WORKDIR /src
8
9COPY go.mod go.sum ./
10RUN go mod download
11
12COPY . /src
13
Akron23711ef2024-03-15 11:26:28 +010014RUN CGO_ENABLED=0 go test .
Akronf09fc562023-01-11 08:47:21 +010015
Akron23711ef2024-03-15 11:26:28 +010016# Build static
17RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
18 go build -v \
19 -ldflags "-extldflags '-static' -s -w" \
20 --trimpath \
21 -o /src/external-big .
Akronf09fc562023-01-11 08:47:21 +010022
Akron23711ef2024-03-15 11:26:28 +010023FROM gruebel/upx:latest as upx
24
25COPY --from=build /src/external-big /external-big
26
27# Compress the binary and copy it to final image
28RUN upx --best --lzma -o /external /external-big
Akronf09fc562023-01-11 08:47:21 +010029
30# Main stage
Akron23711ef2024-03-15 11:26:28 +010031FROM scratch AS final
Akronf09fc562023-01-11 08:47:21 +010032
33WORKDIR /
34
Akron23711ef2024-03-15 11:26:28 +010035EXPOSE 5722
Akronf09fc562023-01-11 08:47:21 +010036
Akron23711ef2024-03-15 11:26:28 +010037COPY --from=build /etc/ssl/certs /etc/ssl/certs
38COPY --from=build /src/templates /templates
39COPY --from=build /src/i18n /i18n
40COPY --from=upx /external /external
41
42ENTRYPOINT [ "/external" ]
Akronf09fc562023-01-11 08:47:21 +010043
44LABEL maintainer="korap@ids-mannheim.de"
45LABEL description="Docker Image for Kalamar-Plugin-ExternalResources, a frontend plugin to link texts to external resources"
Akron23711ef2024-03-15 11:26:28 +010046LABEL repository="https://github.com/KorAP/Kalamar-Plugin-ExternalResources"
Akronf09fc562023-01-11 08:47:21 +010047
Akron23711ef2024-03-15 11:26:28 +010048# docker build -f Dockerfile -t korap/kalamar-plugin-externalresources:latest .
49# docker run --rm --network host -v ${PWD}/db/:/db/:z -v ${PWD}/.env:/.env korap/kalamar-plugin-externalresources:latest