From cd5d0a4a08bf8f305cd64ad835c4309938ce5e4d Mon Sep 17 00:00:00 2001 From: Dan Kanefsky Date: Thu, 10 Oct 2024 13:53:58 -0700 Subject: [PATCH 1/2] chore: update docker --- docker/docker.go | 3 ++- go.mod | 6 ++++-- go.sum | 12 ++++++++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/docker/docker.go b/docker/docker.go index 9fa572b..fcf92ec 100644 --- a/docker/docker.go +++ b/docker/docker.go @@ -10,6 +10,7 @@ import ( "strings" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/client" "github.com/docker/docker/pkg/archive" ) @@ -92,7 +93,7 @@ func BuildDockerImage(ctx context.Context, dockerfile string, tags []string, pus // push all image tags to container registry using provided auth for _, imageTag := range tags { - rd, err := dockerClient.ImagePush(ctx, imageTag, types.ImagePushOptions{ + rd, err := dockerClient.ImagePush(ctx, imageTag, image.PushOptions{ All: true, }) if err != nil { diff --git a/go.mod b/go.mod index de66523..f1d4b97 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module github.com/strangelove-ventures/heighliner go 1.21 require ( - github.com/docker/cli v24.0.4+incompatible - github.com/docker/docker v25.0.6+incompatible + github.com/docker/cli v27.3.1+incompatible + github.com/docker/docker v27.3.1+incompatible github.com/go-git/go-billy/v5 v5.5.0 github.com/go-git/go-git/v5 v5.11.0 github.com/hashicorp/go-version v1.6.0 @@ -54,10 +54,12 @@ require ( github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/klauspost/compress v1.17.2 // indirect + github.com/moby/docker-image-spec v1.3.1 // indirect github.com/moby/patternmatcher v0.5.0 // indirect github.com/moby/sys/sequential v0.5.0 // indirect github.com/moby/sys/signal v0.7.0 // indirect github.com/moby/sys/user v0.3.0 // indirect + github.com/moby/sys/userns v0.1.0 // indirect github.com/moby/term v0.5.0 // indirect github.com/morikuni/aec v1.0.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect diff --git a/go.sum b/go.sum index 2f506a3..15dd707 100644 --- a/go.sum +++ b/go.sum @@ -152,12 +152,12 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= -github.com/docker/cli v24.0.4+incompatible h1:Y3bYF9ekNTm2VFz5U/0BlMdJy73D+Y1iAAZ8l63Ydzw= -github.com/docker/cli v24.0.4+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v27.3.1+incompatible h1:qEGdFBF3Xu6SCvCYhc7CzaQTlBmqDuzxPDpigSyeKQQ= +github.com/docker/cli v27.3.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v25.0.6+incompatible h1:5cPwbwriIcsua2REJe8HqQV+6WlWc1byg2QSXzBxBGg= -github.com/docker/docker v25.0.6+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v27.3.1+incompatible h1:KttF0XoteNTicmUtBO0L2tP+J7FGRFTjaEF4k6WdhfI= +github.com/docker/docker v27.3.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A= github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= @@ -398,6 +398,8 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/moby/buildkit v0.12.5 h1:RNHH1l3HDhYyZafr5EgstEu8aGNCwyfvMtrQDtjH9T0= github.com/moby/buildkit v0.12.5/go.mod h1:YGwjA2loqyiYfZeEo8FtI7z4x5XponAaIWsWcSjWwso= +github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= +github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg= github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc= github.com/moby/patternmatcher v0.5.0 h1:YCZgJOeULcxLw1Q+sVR636pmS7sPEn1Qo2iAN6M7DBo= @@ -410,6 +412,8 @@ github.com/moby/sys/signal v0.7.0 h1:25RW3d5TnQEoKvRbEKUGay6DCQ46IxAVTT9CUMgmsSI github.com/moby/sys/signal v0.7.0/go.mod h1:GQ6ObYZfqacOwTtlXvcmh9A26dVRul/hbOZn88Kg8Tg= github.com/moby/sys/user v0.3.0 h1:9ni5DlcW5an3SvRSx4MouotOygvzaXbaSrc/wGDFWPo= github.com/moby/sys/user v0.3.0/go.mod h1:bG+tYYYJgaMtRKgEmuueC0hJEAZWwtIbZTB+85uoHjs= +github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g= +github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28= github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= From c399caf01dfa41a2c578b6732984aa1b4449ccaa Mon Sep 17 00:00:00 2001 From: Dan Kanefsky Date: Thu, 10 Oct 2024 13:54:21 -0700 Subject: [PATCH 2/2] feat: detect "vendor" folder for local builds --- builder/builder.go | 6 ++++++ dockerfile/cosmos/local.Dockerfile | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/builder/builder.go b/builder/builder.go index 7f56d84..efc3b9c 100644 --- a/builder/builder.go +++ b/builder/builder.go @@ -410,6 +410,11 @@ func (h *HeighlinerBuilder) buildChainNodeDockerImage( chainConfig.Build.BuildDir = "." } + vendor := "false" + if vendorDir, err := os.Stat("vendor"); err == nil && vendorDir.IsDir() { + vendor = "true" + } + buildArgs := map[string]string{ "VERSION": chainConfig.Ref, "BASE_VERSION": gv.Image, @@ -429,6 +434,7 @@ func (h *HeighlinerBuilder) buildChainNodeDockerImage( "BUILD_ENV": buildEnv, "BUILD_TAGS": buildTagsEnvVar, "BUILD_DIR": chainConfig.Build.BuildDir, + "VENDOR": vendor, "BUILD_TIMESTAMP": buildTimestamp, "GO_VERSION": gv.Version, "WASMVM_VERSION": wasmvmVersion, diff --git a/dockerfile/cosmos/local.Dockerfile b/dockerfile/cosmos/local.Dockerfile index 189bd21..a5cea38 100644 --- a/dockerfile/cosmos/local.Dockerfile +++ b/dockerfile/cosmos/local.Dockerfile @@ -37,11 +37,15 @@ RUN if [ ! -z "${CLONE_KEY}" ]; then\ ssh-keyscan github.com >> ~/.ssh/known_hosts;\ fi -# Download go mod dependencies, if there is no custom build directory + +ARG VENDOR + +# Download go mod dependencies, if there is no custom build directory. +# Skips if a go related "vendor" folder is detected. # Note: a custom build dir indicates a monorepo with potential dependencies we can't anticipate atm RUN set -eux; \ - if [[ "${BUILD_DIR}" == "." ]]; then \ - go mod download; \ + if [[ "${BUILD_DIR}" == "." && "${VENDOR}}" == "false" ]]; then\ + go mod download;\ fi; # Use minimal busybox from infra-toolkit image for final scratch image