moth/build/package/Containerfile

30 lines
682 B
Plaintext
Raw Normal View History

2023-12-06 16:44:40 -07:00
ARG GO_VERSION=1.21-alpine
FROM docker.io/library/golang:${GO_VERSION} AS builder
2020-09-17 18:56:40 -06:00
COPY go.* /src/
COPY pkg /src/pkg/
COPY cmd /src/cmd/
COPY theme /target/theme/
COPY example-puzzles /target/puzzles/
COPY LICENSE.md /target/
2020-09-18 17:48:57 -06:00
RUN mkdir -p /target/state
2020-09-17 18:56:40 -06:00
WORKDIR /src/
2021-10-19 17:22:11 -06:00
RUN CGO_ENABLED=0 GOOS=linux go install -a -ldflags '-extldflags "-static"' ./...
2020-09-18 17:48:57 -06:00
# I can't use /target/bin: doing so would cause the devel server to overwrite Ubuntu's /bin
2020-09-17 18:56:40 -06:00
##########
FROM builder AS tester
RUN go test ./...
##########
2020-09-18 17:48:57 -06:00
FROM builder AS prodbuild
RUN mkdir -p /target/bin
RUN cp /go/bin/* /target/bin/
##########
2020-09-17 18:56:40 -06:00
FROM scratch AS moth
2020-09-18 17:48:57 -06:00
COPY --from=prodbuild /target /
ENTRYPOINT [ "/bin/mothd" ]