From 102c2690924342d772a7334be26099bb4dbc8040 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Fri, 18 Sep 2020 17:48:57 -0600 Subject: [PATCH] Fixed up Containerfile --- build/package/Containerfile | 24 +++++++++++++++--------- build/package/build.sh | 2 -- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/build/package/Containerfile b/build/package/Containerfile index 97d9b73..7d8ee24 100644 --- a/build/package/Containerfile +++ b/build/package/Containerfile @@ -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" ] diff --git a/build/package/build.sh b/build/package/build.sh index c9913a0..abf9163 100755 --- a/build/package/build.sh +++ b/build/package/build.sh @@ -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