blob: 967f8bf84320b8cea8c9e3f15ab0726aae2a284d [file] [log] [blame]
Akron50d5f832025-06-06 15:08:04 +02001# Build stage
2FROM golang:latest AS build
3
4RUN apt-get update && \
5 apt-get upgrade -y ca-certificates
6
7WORKDIR /src
8
9COPY go.mod go.sum ./
10RUN go mod download
11
12COPY . /src
13
14RUN CGO_ENABLED=0 go test ./...
15
16# Build static
17RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
18 go build -v \
19 -ldflags "-extldflags '-static' -s -w" \
20 --trimpath \
Akron2ef703c2025-07-03 15:57:42 +020021 -o /src/koralmapper ./cmd/koralmapper/
Akron50d5f832025-06-06 15:08:04 +020022
23FROM gruebel/upx:latest AS upx
24
Akron2ef703c2025-07-03 15:57:42 +020025COPY --from=build /src/koralmapper /koralmapper-big
Akron50d5f832025-06-06 15:08:04 +020026
27# Compress the binary and copy it to final image
Akron2ef703c2025-07-03 15:57:42 +020028RUN upx --best --lzma -o /koralmapper /koralmapper-big
Akron50d5f832025-06-06 15:08:04 +020029
30# Main stage
31FROM scratch AS final
32
33WORKDIR /
34
35EXPOSE 5725
36
37COPY --from=build /etc/ssl/certs /etc/ssl/certs
38COPY --from=build /src/mappings /mappings
Akron2ef703c2025-07-03 15:57:42 +020039COPY --from=upx /koralmapper /koralmapper
Akron50d5f832025-06-06 15:08:04 +020040
Akron8f1bef92025-07-04 14:54:02 +020041ENTRYPOINT [ "/koralmapper" ]
Akron50d5f832025-06-06 15:08:04 +020042
43LABEL maintainer="korap@ids-mannheim.de"
Akron2ef703c2025-07-03 15:57:42 +020044LABEL description="Docker Image for Koral-Mapper"
45LABEL repository="https://github.com/KorAP/Koral-Mapper"
Akron50d5f832025-06-06 15:08:04 +020046
Akron2ef703c2025-07-03 15:57:42 +020047# docker build -f Dockerfile -t korap/koral-mapper:latest .
48# docker run --rm --network host korap/koral-mapper:latest -m /mappings/*.yaml
49# docker save -o korap-koral-mapper-latest.tar korap/koral-mapper:latest