From 971e5b6e2c7a3c5764d26bae49517b0d5c4fd1b5 Mon Sep 17 00:00:00 2001 From: gfanton <8671905+gfanton@users.noreply.github.com> Date: Thu, 18 Apr 2024 19:22:23 +0200 Subject: [PATCH] feat: add build gnofaucet layer Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com> --- Dockerfile | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index d55771e904d..a18c7125a82 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,28 @@ -# build -FROM golang:1.22 AS build +# build gno +FROM golang:1.22 AS build-gno RUN mkdir -p /opt/gno/src /opt/build WORKDIR /opt/build -ADD go.mod go.sum ./ +ADD go.mod go.sum . RUN go mod download ADD . ./ RUN go build -o ./build/gnoland ./gno.land/cmd/gnoland RUN go build -o ./build/gnokey ./gno.land/cmd/gnokey -RUN go build -o ./build/gnofaucet ./gno.land/cmd/gnofaucet RUN go build -o ./build/gnoweb ./gno.land/cmd/gnoweb RUN go build -o ./build/gno ./gnovm/cmd/gno RUN ls -la ./build ADD . /opt/gno/src/ RUN rm -rf /opt/gno/src/.git +# build faucet +FROM golang:1.22 AS build-faucet +RUN mkdir -p /opt/gno/src /opt/build +WORKDIR /opt/build +ADD contribs/gnofaucet/go.mod contribs/gnofaucet/go.sum . +RUN go mod download +ADD contribs/gnofaucet ./ +RUN go build -o ./build/gnofaucet . + + # runtime-base + runtime-tls FROM debian:stable-slim AS runtime-base ENV PATH="${PATH}:/opt/gno/bin" \ @@ -25,32 +34,33 @@ RUN apt-get update && apt-get install -y expect ca-certificates && updat # slim images FROM runtime-base AS gnoland-slim WORKDIR /opt/gno/src/gno.land/ -COPY --from=build /opt/build/build/gnoland /opt/gno/bin/ +COPY --from=build-gno /opt/build/build/gnoland /opt/gno/bin/ ENTRYPOINT ["gnoland"] EXPOSE 26657 36657 FROM runtime-base AS gnokey-slim -COPY --from=build /opt/build/build/gnokey /opt/gno/bin/ +COPY --from=build-gno /opt/build/build/gnokey /opt/gno/bin/ ENTRYPOINT ["gnokey"] FROM runtime-base AS gno-slim -COPY --from=build /opt/build/build/gno /opt/gno/bin/ +COPY --from=build-gno /opt/build/build/gno /opt/gno/bin/ ENTRYPOINT ["gno"] FROM runtime-tls AS gnofaucet-slim -COPY --from=build /opt/build/build/gnofaucet /opt/gno/bin/ +COPY --from=build-faucet /opt/build/build/gnofaucet /opt/gno/bin/ ENTRYPOINT ["gnofaucet"] EXPOSE 5050 FROM runtime-tls AS gnoweb-slim -COPY --from=build /opt/build/build/gnoweb /opt/gno/bin/ -COPY --from=build /opt/gno/src/gno.land/cmd/gnoweb /opt/gno/src/gnoweb +COPY --from=build-gno /opt/build/build/gnoweb /opt/gno/bin/ +COPY --from=build-gno /opt/gno/src/gno.land/cmd/gnoweb /opt/gno/src/gnoweb ENTRYPOINT ["gnoweb"] EXPOSE 8888 # all, contains everything. FROM runtime-tls AS all -COPY --from=build /opt/build/build/* /opt/gno/bin/ -COPY --from=build /opt/gno/src /opt/gno/src +COPY --from=build-gno /opt/build/build/* /opt/gno/bin/ +COPY --from=build-faucet /opt/build/build/* /opt/gno/bin/ +COPY --from=build-gno /opt/gno/src /opt/gno/src # gofmt is required by `gnokey maketx addpkg` -COPY --from=build /usr/local/go/bin/gofmt /usr/bin +COPY --from=build-gno /usr/local/go/bin/gofmt /usr/bin