-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
30 lines (23 loc) · 855 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# syntax = docker.io/docker/dockerfile:1.9
ARG ALPINE_BASE=docker.io/library/alpine:3.20
ARG GOLANG_BASE=docker.io/library/golang:1.23-alpine3.20
FROM --platform=$BUILDPLATFORM $GOLANG_BASE AS build
ENV CGO_ENABLED=0
ARG TARGETPLATFORM
RUN \
--mount=type=bind,target=/mnt/randomizer \
--mount=type=cache,id=randomizer.go-pkg,target=/go/pkg \
--mount=type=cache,id=randomizer.go-build,target=/root/.cache/go-build \
cd /mnt/randomizer && \
source ./targetplatform-go-env.sh && \
go build -v \
-mod=vendor \
-ldflags='-s -w' \
-o /randomizer-server \
./cmd/randomizer-server
FROM scratch AS server-binary
COPY --link --from=build /randomizer-server /
FROM $ALPINE_BASE AS server-image
COPY --link --from=build /randomizer-server /usr/local/bin/randomizer-server
EXPOSE 7636
ENTRYPOINT ["/usr/local/bin/randomizer-server"]