Multi-stage build: compiles with CGO disabled in golang:1.25-alpine, runs the static binary in a plain alpine:3.20 image. Defaults to "share relay" on port 9009; override with extra args at `docker run`.
13 lines
255 B
Docker
13 lines
255 B
Docker
FROM golang:1.25-alpine AS build
|
|
WORKDIR /src
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
COPY . .
|
|
RUN CGO_ENABLED=0 go build -o /out/share .
|
|
|
|
FROM alpine:3.20
|
|
COPY --from=build /out/share /usr/local/bin/share
|
|
EXPOSE 9009
|
|
ENTRYPOINT ["share"]
|
|
CMD ["relay"]
|