| 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 | |
| Akron | f22317d | 2026-02-25 11:37:59 +0100 | [diff] [blame^] | 16 | ARG BUILDDATE="[unset]" |
| 17 | ARG BUILDCOMMIT="[unset]" |
| 18 | ARG BUILDVERSION="EARLY" |
| 19 | |
| Akron | 50d5f83 | 2025-06-06 15:08:04 +0200 | [diff] [blame] | 20 | # Build static |
| 21 | RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \ |
| 22 | go build -v \ |
| Akron | f22317d | 2026-02-25 11:37:59 +0100 | [diff] [blame^] | 23 | -ldflags "-X github.com/KorAP/Koral-Mapper/config.Buildtime=${BUILDDATE} -X github.com/KorAP/Koral-Mapper/config.Buildhash=${BUILDCOMMIT} -X github.com/KorAP/Koral-Mapper/config.Version=${BUILDVERSION} -extldflags '-static' -s -w" \ |
| Akron | 50d5f83 | 2025-06-06 15:08:04 +0200 | [diff] [blame] | 24 | --trimpath \ |
| Akron | 2ef703c | 2025-07-03 15:57:42 +0200 | [diff] [blame] | 25 | -o /src/koralmapper ./cmd/koralmapper/ |
| Akron | 50d5f83 | 2025-06-06 15:08:04 +0200 | [diff] [blame] | 26 | |
| 27 | FROM gruebel/upx:latest AS upx |
| 28 | |
| Akron | 2ef703c | 2025-07-03 15:57:42 +0200 | [diff] [blame] | 29 | COPY --from=build /src/koralmapper /koralmapper-big |
| Akron | 50d5f83 | 2025-06-06 15:08:04 +0200 | [diff] [blame] | 30 | |
| 31 | # Compress the binary and copy it to final image |
| Akron | 2ef703c | 2025-07-03 15:57:42 +0200 | [diff] [blame] | 32 | RUN upx --best --lzma -o /koralmapper /koralmapper-big |
| Akron | 50d5f83 | 2025-06-06 15:08:04 +0200 | [diff] [blame] | 33 | |
| 34 | # Main stage |
| 35 | FROM scratch AS final |
| 36 | |
| 37 | WORKDIR / |
| 38 | |
| 39 | EXPOSE 5725 |
| 40 | |
| Akron | f22317d | 2026-02-25 11:37:59 +0100 | [diff] [blame^] | 41 | ARG BUILDVERSION="EARLY" |
| 42 | ARG BUILDCOMMIT="[unset]" |
| 43 | ARG BUILDDATE="1970-01-01T00:00:00Z" |
| 44 | |
| Akron | 50d5f83 | 2025-06-06 15:08:04 +0200 | [diff] [blame] | 45 | COPY --from=build /etc/ssl/certs /etc/ssl/certs |
| 46 | COPY --from=build /src/mappings /mappings |
| Akron | 2ef703c | 2025-07-03 15:57:42 +0200 | [diff] [blame] | 47 | COPY --from=upx /koralmapper /koralmapper |
| Akron | 50d5f83 | 2025-06-06 15:08:04 +0200 | [diff] [blame] | 48 | |
| Akron | 8f1bef9 | 2025-07-04 14:54:02 +0200 | [diff] [blame] | 49 | ENTRYPOINT [ "/koralmapper" ] |
| Akron | 50d5f83 | 2025-06-06 15:08:04 +0200 | [diff] [blame] | 50 | |
| 51 | LABEL maintainer="korap@ids-mannheim.de" |
| Akron | 2ef703c | 2025-07-03 15:57:42 +0200 | [diff] [blame] | 52 | LABEL description="Docker Image for Koral-Mapper" |
| 53 | LABEL repository="https://github.com/KorAP/Koral-Mapper" |
| Akron | f22317d | 2026-02-25 11:37:59 +0100 | [diff] [blame^] | 54 | LABEL org.opencontainers.image.title="Koral-Mapper" |
| 55 | LABEL org.opencontainers.image.description="Docker Image for Koral-Mapper" |
| 56 | LABEL org.opencontainers.image.url="https://github.com/KorAP/Koral-Mapper" |
| 57 | LABEL org.opencontainers.image.source="https://github.com/KorAP/Koral-Mapper" |
| 58 | LABEL org.opencontainers.image.created="${BUILDDATE}" |
| 59 | LABEL org.opencontainers.image.revision="${BUILDCOMMIT}" |
| 60 | LABEL org.opencontainers.image.version="${BUILDVERSION}" |
| Akron | 50d5f83 | 2025-06-06 15:08:04 +0200 | [diff] [blame] | 61 | |
| Akron | 2ef703c | 2025-07-03 15:57:42 +0200 | [diff] [blame] | 62 | # docker build -f Dockerfile -t korap/koral-mapper:latest . |
| 63 | # docker run --rm --network host korap/koral-mapper:latest -m /mappings/*.yaml |
| 64 | # docker save -o korap-koral-mapper-latest.tar korap/koral-mapper:latest |