From cc1cbc5f0a1f4a439042fa0ccd937ef0236cc6ca Mon Sep 17 00:00:00 2001 From: "Han Verstraete (OpenFaaS Ltd)" Date: Thu, 16 Jan 2025 15:42:01 +0100 Subject: [PATCH] Use vendored modules in image build Use vendor folder instead of running go mod download during the build. Update .dockerignore Signed-off-by: Han Verstraete (OpenFaaS Ltd) --- .dockerignore | 17 ++++++++++++++++- Dockerfile | 18 +++--------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.dockerignore b/.dockerignore index bbf58a4b..6c5ca27f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,16 @@ -./inlets-operator \ No newline at end of file +./inlets-operator +.tools +chart +hack +docs +contrib +LICENSE +Makefile +*.md + +.git +.dockerignore +Dockerfile +.github +.gitignore +.DEREK.yml \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 79035c77..161c188f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -FROM --platform=${BUILDPLATFORM:-linux/amd64} ghcr.io/openfaas/license-check:0.4.1 as license-check -FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.23 as builder +FROM --platform=${BUILDPLATFORM:-linux/amd64} ghcr.io/openfaas/license-check:0.4.1 AS license-check +FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.23 AS builder ARG TARGETPLATFORM ARG BUILDPLATFORM @@ -17,19 +17,7 @@ COPY --from=license-check /license-check /usr/bin/ RUN mkdir -p /go/src/github.com/inlets/inlets-operator WORKDIR /go/src/github.com/inlets/inlets-operator -# Cache the download before continuing -COPY go.mod go.mod -COPY go.sum go.sum -RUN go mod download - -COPY pkg pkg -COPY main.go main.go -COPY image_test.go image_test.go -COPY controller.go controller.go -COPY validate.go validate.go -COPY validate_test.go validate_test.go -COPY config.go config.go -COPY config_test.go config_test.go +COPY . . RUN gofmt -l -d $(find . -type f -name '*.go' -not -path "./vendor/*")