sliding-sync/Dockerfile

26 lines
802 B
Docker
Raw Normal View History

FROM docker.io/golang:1.20-alpine AS base
2021-10-10 12:20:18 +01:00
WORKDIR /build
2023-01-12 08:40:41 +01:00
RUN apk --update --no-cache add build-base git
ARG BINARYNAME=syncv3
2023-01-12 08:40:41 +01:00
RUN --mount=target=. \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
GIT_COMMIT=$(git rev-list -1 HEAD) && \
2023-05-09 18:21:43 +01:00
go build -ldflags "-X main.GitCommit=$GIT_COMMIT" -trimpath -o /out/syncv3 "./cmd/$BINARYNAME"
2021-10-10 12:20:18 +01:00
2023-01-12 18:08:43 +01:00
FROM alpine:3.17
2021-10-10 12:20:18 +01:00
RUN apk --update --no-cache add curl
2023-01-12 08:40:41 +01:00
COPY --from=base /out/* /usr/bin/
2021-10-10 12:20:18 +01:00
ENV SYNCV3_BINDADDR="0.0.0.0:8008"
EXPOSE 8008
WORKDIR /usr/bin
2023-05-09 18:21:43 +01:00
# It would be nice if the binary we exec was called $BINARYNAME here, but build args
# aren't expanded in ENTRYPOINT directives. Instead, we always call the output binary
# "syncv3". (See https://github.com/moby/moby/issues/18492)
2022-07-27 11:02:31 +01:00
ENTRYPOINT /usr/bin/syncv3