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 go.* /src/
COPY pkg /src/pkg/ COPY pkg /src/pkg/
COPY cmd /src/cmd/ COPY cmd /src/cmd/
COPY theme /target/theme/ COPY theme /target/theme/
COPY example-puzzles /target/puzzles/ COPY example-puzzles /target/puzzles/
COPY LICENSE.md /target/ COPY LICENSE.md /target/
RUN mkdir -p /target/state
WORKDIR /src/ WORKDIR /src/
RUN CGO_ENABLED=0 GOOS=linux go install -i -a -ldflags '-extldflags "-static"' ./... RUN CGO_ENABLED=0 GOOS=linux go install -i -a -ldflags '-extldflags "-static"' ./...
# I can't use /target/bin: doing so would cause the devel server to overwrite Ubuntu's /bin
# 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/
########## ##########
@ -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 FROM scratch AS moth
COPY --from=builder /target / COPY --from=prodbuild /target /
ENTRYPOINT [ "/mothd" ] ENTRYPOINT [ "/bin/mothd" ]
########## ##########
@ -34,6 +38,8 @@ RUN apt-get -y update && apt-get -y install \
python3 \ python3 \
python3-pil \ python3-pil \
python3-scapy \ python3-scapy \
python3-yaml \
cowsay cowsay
COPY --from=builder /bin/* / COPY --from=builder /target /
CMD [ "/mothd", "-puzzles", "/puzzles" ] 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 \ $PODMAN build \
--build-arg http_proxy --build-arg https_proxy --build-arg no_proxy \ --build-arg http_proxy --build-arg https_proxy --build-arg no_proxy \
--tag dirtbags/$target \ --tag dirtbags/$target \
--tag dirtbags/$target:$VERSION \
--target $target \ --target $target \
-f build/package/Containerfile . -f build/package/Containerfile .
[ "$1" = "-push" ] && docker push dirtbags/$target:$VERSION && docker push dirtbags/$img:latest
done done
exit 0 exit 0