Akron | 50d5f83 | 2025-06-06 15:08:04 +0200 | [diff] [blame] | 1 | # Build stage |
| 2 | FROM golang:latest AS build |
| 3 | |
| 4 | RUN apt-get update && \ |
| 5 | apt-get upgrade -y ca-certificates |
| 6 | |
| 7 | WORKDIR /src |
| 8 | |
| 9 | COPY go.mod go.sum ./ |
| 10 | RUN go mod download |
| 11 | |
| 12 | COPY . /src |
| 13 | |
| 14 | RUN CGO_ENABLED=0 go test ./... |
| 15 | |
| 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/termmapper ./cmd/termmapper/ |
| 22 | |
| 23 | FROM gruebel/upx:latest AS upx |
| 24 | |
| 25 | COPY --from=build /src/termmapper /termmapper-big |
| 26 | |
| 27 | # Compress the binary and copy it to final image |
| 28 | RUN upx --best --lzma -o /termmapper /termmapper-big |
| 29 | |
| 30 | # Main stage |
| 31 | FROM scratch AS final |
| 32 | |
| 33 | WORKDIR / |
| 34 | |
| 35 | EXPOSE 5725 |
| 36 | |
| 37 | COPY --from=build /etc/ssl/certs /etc/ssl/certs |
| 38 | COPY --from=build /src/mappings /mappings |
| 39 | COPY --from=upx /termmapper /termmapper |
| 40 | |
| 41 | ENTRYPOINT [ "/termmapper" ] |
| 42 | |
| 43 | LABEL maintainer="korap@ids-mannheim.de" |
| 44 | LABEL description="Docker Image for KoralPipe-TermMapper" |
| 45 | LABEL repository="https://github.com/KorAP/KoralPipe-TermMapper" |
| 46 | |
| 47 | # docker build -f Dockerfile -t korap/koralpipe-termmapper:latest . |
| 48 | # docker run --rm --network host korap/koralpipe-termmapper:latest -m /mappings/*.yaml |