11# Build stage
22FROM golang:latest as build
3+
4+ RUN apt-get update && \
5+ apt-get upgrade -y ca-certificates
6+
37WORKDIR /src
48
59COPY go.mod go.sum ./
610RUN go mod download
711
812COPY . /src
913
10- RUN apt-get update && \
11- apt-get upgrade -y ca-certificates
14+ RUN CGO_ENABLED=0 go test .
1215
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 .
1422
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
1824
19- # Main stage
20- FROM busybox:glibc
25+ COPY --from=build /src/external-big /external-big
2126
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
2332
2433WORKDIR /
2534
35+ EXPOSE 5722
36+
2637COPY --from=build /etc/ssl/certs /etc/ssl/certs
27- COPY --from=build /src/kalamar-plugin-externalresources /kalamar-plugin-externalresources
2838COPY --from=build /src/templates /templates
39+ COPY --from=build /src/i18n /i18n
40+ COPY --from=upx /external /external
2941
30- ENTRYPOINT [ "./kalamar-plugin-externalresources " ]
42+ ENTRYPOINT [ "/external " ]
3143
3244LABEL maintainer=
"[email protected] " 3345LABEL 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 "
3547
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