From 09ffab40558d758e2e55b564f6a861e45f8e0561 Mon Sep 17 00:00:00 2001 From: Willy Date: Fri, 3 Feb 2023 20:31:47 +0100 Subject: [PATCH] improve docker cachability --- .github/workflows/build.yml | 1 + Dockerfile | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f3b1f1d1..354ebc19 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -441,6 +441,7 @@ jobs: args: | COMMIT=${{ github.sha }} VERSION=${{ needs.data.outputs.version }} + BUILDKIT_INLINE_CACHE=true # all other release jobs should be based on this release: diff --git a/Dockerfile b/Dockerfile index 46881acf..9453abe1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,9 +10,6 @@ RUN yarn build && yarn cache clean # Statping Golang BACKEND building from source # Creates "/go/bin/statping" and "/usr/local/bin/sass" for copying -# TODO something here breaks caching / forces a rebuild each time. fix -# * probably the COPY . . -# * also, the sass git clone isn't reproducible, we should version-pin that FROM golang:1.19-alpine AS backend LABEL maintainer="Statping-NG (https://github.com/statping-ng)" ARG VERSION @@ -24,7 +21,7 @@ RUN apk add --update --no-cache libstdc++ gcc g++ make git autoconf \ update-ca-certificates WORKDIR /root -RUN git clone https://github.com/sass/sassc.git +RUN git clone --depth 1 --branch 3.6.2 https://github.com/sass/sassc.git RUN . sassc/script/bootstrap && make -C sassc -j4 # sassc binary: /root/sassc/bin/sassc @@ -33,7 +30,12 @@ ADD go.mod go.sum ./ RUN go mod download ENV GO111MODULE on ENV CGO_ENABLED 1 -COPY . . +COPY cmd ./cmd +COPY database ./database +COPY handlers ./handlers +COPY source ./source +COPY types ./types +COPY utils ./utils COPY --from=frontend /statping/dist/ ./source/dist/ RUN go install github.com/GeertJohan/go.rice/rice@latest RUN cd source && rice embed-go