From f25e1965a1645f8e0d29f4e871f5783db958b210 Mon Sep 17 00:00:00 2001 From: Morgan Bazalgette Date: Tue, 29 Oct 2024 21:18:58 +0100 Subject: [PATCH] attempt to unfuck dockerfiles --- .github/workflows/autocounterd.yml | 4 +++- .github/workflows/portal-loop.yml | 3 --- Dockerfile | 26 +++++++++++++++++++++++++- Dockerfile.release | 3 +++ misc/autocounterd/Dockerfile | 16 ---------------- misc/autocounterd/docker-compose.yml | 3 ++- misc/loop/Dockerfile | 19 ------------------- misc/loop/docker-compose.yml | 2 +- 8 files changed, 34 insertions(+), 42 deletions(-) delete mode 100644 misc/autocounterd/Dockerfile delete mode 100644 misc/loop/Dockerfile diff --git a/.github/workflows/autocounterd.yml b/.github/workflows/autocounterd.yml index 66aced0d89c..63799960df5 100644 --- a/.github/workflows/autocounterd.yml +++ b/.github/workflows/autocounterd.yml @@ -1,6 +1,9 @@ name: autocounterd on: + pull_request: + branches: + - master push: paths: - misc/autocounterd @@ -41,7 +44,6 @@ jobs: - name: Build and push uses: docker/build-push-action@v6 with: - context: ./misc/autocounterd push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/portal-loop.yml b/.github/workflows/portal-loop.yml index b81957b22db..2fe7a90d0b0 100644 --- a/.github/workflows/portal-loop.yml +++ b/.github/workflows/portal-loop.yml @@ -45,7 +45,6 @@ jobs: - name: Build and push uses: docker/build-push-action@v6 with: - context: ./misc/loop target: portalloopd push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} @@ -60,8 +59,6 @@ jobs: - name: "Setup the images" run: | - cd misc/loop - docker compose build docker compose pull docker compose up -d diff --git a/Dockerfile b/Dockerfile index fa5a9e47270..b858589640f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,11 +10,20 @@ RUN --mount=type=cache,target=/root/.cache/go-build go build -o ./ RUN --mount=type=cache,target=/root/.cache/go-build go build -o ./build/gnoweb ./gno.land/cmd/gnoweb RUN --mount=type=cache,target=/root/.cache/go-build go build -o ./build/gno ./gnovm/cmd/gno +# build misc binaries +FROM golang:1.22-alpine AS build-misc +RUN go env -w GOMODCACHE=/root/.cache/go-build +WORKDIR /gnoroot +ENV GNOROOT="/gnoroot" +COPY . ./ +RUN --mount=type=cache,target=/root/.cache/go-build go build -C ./misc/loop -o /gnoroot/build/portalloopd ./cmd +RUN --mount=type=cache,target=/root/.cache/go-build go build -C ./misc/autocounterd -o /gnoroot/build/autocounterd ./cmd + # Base image FROM alpine:3.17 AS base WORKDIR /gnoroot ENV GNOROOT="/gnoroot" -RUN apk add ca-certificates +RUN apk add --no-cache ca-certificates CMD [ "" ] # alpine images @@ -47,6 +56,21 @@ COPY --from=build-gno /opt/gno/src/gno.land/cmd/gnoweb /opt/gno/src/gnowe EXPOSE 8888 ENTRYPOINT ["/usr/bin/gnoweb"] +# misc/loop +FROM docker AS portalloopd +WORKDIR /gnoroot +ENV GNOROOT="/gnoroot" +RUN apk add --no-cache ca-certificates bash curl jq +COPY --from=build-misc /gnoroot/build/portalloopd /usr/bin/portalloopd +ENTRYPOINT ["/usr/bin/portalloopd"] +CMD ["serve"] + +# misc/autocounterd +FROM base AS autocounterd +COPY --from=build-misc /gnoroot/build/autocounterd /usr/bin/autocounterd +ENTRYPOINT ["/usr/bin/autocounterd"] +CMD ["start"] + # all, contains everything. FROM base AS all COPY --from=build-gno /gnoroot/build/* /usr/bin/ diff --git a/Dockerfile.release b/Dockerfile.release index 4887857b5c2..481100c85c3 100644 --- a/Dockerfile.release +++ b/Dockerfile.release @@ -1,3 +1,6 @@ +# This file is similar to Dockerfile, but assumes that the binaries have +# already been created, and as such doesn't `go build` them. + FROM alpine AS base ENV GNOROOT="/gnoroot/" diff --git a/misc/autocounterd/Dockerfile b/misc/autocounterd/Dockerfile deleted file mode 100644 index d860fc5f37f..00000000000 --- a/misc/autocounterd/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM golang:alpine AS builder - -COPY . /go/src/github.com/gnolang/gno/misc/autocounterd - -WORKDIR /go/src/github.com/gnolang/gno/misc/autocounterd - -RUN go build -o /build/autocounterd ./cmd - -# Final image for autocounterd -FROM alpine AS autocounterd - -COPY --from=builder /build/autocounterd /usr/bin/autocounterd - -ENTRYPOINT [ "/usr/bin/autocounterd" ] -CMD [ "start" ] - diff --git a/misc/autocounterd/docker-compose.yml b/misc/autocounterd/docker-compose.yml index d71e6997b51..49d1ad413f3 100644 --- a/misc/autocounterd/docker-compose.yml +++ b/misc/autocounterd/docker-compose.yml @@ -3,7 +3,8 @@ services: autocounterd: image: ghcr.io/gnolang/gno/autocounterd build: - context: . + context: ../.. + target: autocounterd restart: unless-stopped environment: COUNTER_MNEMONIC: "source bonus chronic canvas draft south burst lottery vacant surface solve popular case indicate oppose farm nothing bullet exhibit title speed wink action roast" diff --git a/misc/loop/Dockerfile b/misc/loop/Dockerfile deleted file mode 100644 index 219a47927db..00000000000 --- a/misc/loop/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -FROM golang:alpine AS builder - -COPY . /go/src/github.com/gnolang/gno/misc/loop - -WORKDIR /go/src/github.com/gnolang/gno/misc/loop - -RUN --mount=type=cache,target=/root/.cache/go-build \ - --mount=type=cache,target=/root/go/pkg/mod \ - go build -o /build/portalloopd ./cmd - -# Final image for portalloopd -FROM docker AS portalloopd - -RUN apk add bash curl jq - -COPY --from=builder /build/portalloopd /usr/bin/portalloopd - -ENTRYPOINT [ "/usr/bin/portalloopd" ] -CMD [ "serve" ] diff --git a/misc/loop/docker-compose.yml b/misc/loop/docker-compose.yml index eba0f55e787..ed2fe7192f5 100644 --- a/misc/loop/docker-compose.yml +++ b/misc/loop/docker-compose.yml @@ -68,7 +68,7 @@ services: portalloopd: build: - context: . + context: ../.. target: portalloopd restart: unless-stopped volumes: