From 9b28fbc24ddad49b29146fe48fad78cac02838e4 Mon Sep 17 00:00:00 2001 From: jebabin Date: Mon, 18 Sep 2023 14:30:32 +0200 Subject: [PATCH] chore: update Dockerfile.dev-self-contained to allow better build cache (#1755) --- dockerfiles/Dockerfile.dev-self-contained | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dockerfiles/Dockerfile.dev-self-contained b/dockerfiles/Dockerfile.dev-self-contained index 7126459..1a39c26 100644 --- a/dockerfiles/Dockerfile.dev-self-contained +++ b/dockerfiles/Dockerfile.dev-self-contained @@ -7,6 +7,13 @@ FROM golang:alpine as builder # use version (for example "v0.3.3") or "main" ARG WATCHTOWER_VERSION=main +# Pre download required modules to avoid redownloading at each build thanks to docker layer caching. +# Copying go.mod and go.sum ensure to invalid the layer/build cache if there is a change in module requirement +WORKDIR /watchtower +COPY go.mod . +COPY go.sum . +RUN go mod download + RUN apk add --no-cache \ alpine-sdk \ ca-certificates \