Fixed up Containerfile

This commit is contained in:
Neale Pickett 2020-09-18 17:48:57 -06:00
parent 97921b6776
commit 102c269092
2 changed files with 15 additions and 11 deletions

View File

@ -1,16 +1,14 @@
FROM golang:1-alpine AS builder
FROM golang:1 AS builder
COPY go.* /src/
COPY pkg /src/pkg/
COPY cmd /src/cmd/
COPY theme /target/theme/
COPY example-puzzles /target/puzzles/
COPY LICENSE.md /target/
RUN mkdir -p /target/state
WORKDIR /src/
RUN CGO_ENABLED=0 GOOS=linux go install -i -a -ldflags '-extldflags "-static"' ./...
# I can't put these in /target/bin: doing so would cause the devel server to overwrite Ubuntu's /bin
RUN mkdir -p /target/bin/
RUN cp /go/bin/* /target/
# I can't use /target/bin: doing so would cause the devel server to overwrite Ubuntu's /bin
##########
@ -19,9 +17,15 @@ RUN go test ./...
##########
FROM builder AS prodbuild
RUN mkdir -p /target/bin
RUN cp /go/bin/* /target/bin/
##########
FROM scratch AS moth
COPY --from=builder /target /
ENTRYPOINT [ "/mothd" ]
COPY --from=prodbuild /target /
ENTRYPOINT [ "/bin/mothd" ]
##########
@ -34,6 +38,8 @@ RUN apt-get -y update && apt-get -y install \
python3 \
python3-pil \
python3-scapy \
python3-yaml \
cowsay
COPY --from=builder /bin/* /
CMD [ "/mothd", "-puzzles", "/puzzles" ]
COPY --from=builder /target /
COPY --from=builder /go/bin/* /bin/
CMD [ "/bin/mothd", "-puzzles", "/puzzles" ]

View File

@ -13,10 +13,8 @@ for target in moth moth-devel; do
$PODMAN build \
--build-arg http_proxy --build-arg https_proxy --build-arg no_proxy \
--tag dirtbags/$target \
--tag dirtbags/$target:$VERSION \
--target $target \
-f build/package/Containerfile .
[ "$1" = "-push" ] && docker push dirtbags/$target:$VERSION && docker push dirtbags/$img:latest
done
exit 0