1
1
# Build stage
2
2
FROM golang:latest as build
3
+
4
+ RUN apt-get update && \
5
+ apt-get upgrade -y ca-certificates
6
+
3
7
WORKDIR /src
4
8
5
9
COPY go.mod go.sum ./
6
10
RUN go mod download
7
11
8
12
COPY . /src
9
13
10
- RUN apt-get update && \
11
- apt-get upgrade -y ca-certificates
14
+ RUN CGO_ENABLED=0 go test .
12
15
13
- RUN go test .
16
+ # Build static
17
+ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
18
+ go build -v \
19
+ -ldflags "-extldflags '-static' -s -w" \
20
+ --trimpath \
21
+ -o /src/external-big .
14
22
15
- RUN STATIC="-extldflags '-static'" \
16
- STATICENV="CGO_ENABLED=0 GOOS=linux GOARCH=amd64" \
17
- go build -o /src/kalamar-plugin-externalresources .
23
+ FROM gruebel/upx:latest as upx
18
24
19
- # Main stage
20
- FROM busybox:glibc
25
+ COPY --from=build /src/external-big /external-big
21
26
22
- EXPOSE 5722
27
+ # Compress the binary and copy it to final image
28
+ RUN upx --best --lzma -o /external /external-big
29
+
30
+ # Main stage
31
+ FROM scratch AS final
23
32
24
33
WORKDIR /
25
34
35
+ EXPOSE 5722
36
+
26
37
COPY --from=build /etc/ssl/certs /etc/ssl/certs
27
- COPY --from=build /src/kalamar-plugin-externalresources /kalamar-plugin-externalresources
28
38
COPY --from=build /src/templates /templates
39
+ COPY --from=build /src/i18n /i18n
40
+ COPY --from=upx /external /external
29
41
30
- ENTRYPOINT [ "./kalamar-plugin-externalresources " ]
42
+ ENTRYPOINT [ "/external " ]
31
43
32
44
LABEL maintainer="korap@ids-mannheim.de"
33
45
LABEL description="Docker Image for Kalamar-Plugin-ExternalResources, a frontend plugin to link texts to external resources"
34
- LABEL repository="https://github.com/KorAP/... "
46
+ LABEL repository="https://github.com/KorAP/Kalamar-Plugin-ExternalResources "
35
47
36
- # docker build -f Dockerfile -t korap/kalamar-plugin-externalresources .
37
- # docker run --rm --network host -v ${PWD}/db/:/db/:z -v ${PWD}/.env:/.env korap/kalamar-plugin-externalresources
48
+ # 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
0 commit comments