Skip to content

Commit

Permalink
feat: allow pre clone logic
Browse files Browse the repository at this point in the history
  • Loading branch information
johnletey committed May 29, 2024
1 parent 713e8b2 commit 621cc41
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ func (h *HeighlinerBuilder) buildChainNodeDockerImage(
"TARGET_LIBRARIES": targetLibraries,
"DIRECTORIES": directories,
"PRE_BUILD": chainConfig.Build.PreBuild,
"PRE_CLONE": chainConfig.Build.PreClone,
"FINAL_IMAGE": chainConfig.Build.FinalImage,
"BUILD_ENV": buildEnv,
"BUILD_TAGS": buildTagsEnvVar,
Expand Down
1 change: 1 addition & 0 deletions builder/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type ChainNodeConfig struct {
TargetLibraries []string `yaml:"target-libraries"`
Directories []string `yaml:"directories"`
PreBuild string `yaml:"pre-build"`
PreClone string `yaml:"pre-clone"`
Platforms []string `yaml:"platforms"`
BuildEnv []string `yaml:"build-env"`
BaseImage string `yaml:"base-image"`
Expand Down
3 changes: 3 additions & 0 deletions cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type chainConfigFlags struct {
dockerfileOverride string
buildDirOverride string
preBuildOverride string
preCloneOverride string
buildTargetOverride string
buildEnvOverride string
binariesOverride string
Expand All @@ -45,6 +46,7 @@ const (
flagDockerfile = "dockerfile"
flagBuildDir = "build-dir"
flagPreBuild = "pre-build"
flagPreClone = "pre-clone"
flagBuildTarget = "build-target"
flagBuildEnv = "build-env"
flagBinaries = "binaries"
Expand Down Expand Up @@ -153,6 +155,7 @@ An optional flag --tag/-t is now available to override the resulting docker imag
buildCmd.PersistentFlags().StringVar(&chainConfig.dockerfileOverride, flagDockerfile, "", "dockerfile override (cosmos, cargo, imported, none)")
buildCmd.PersistentFlags().StringVar(&chainConfig.buildDirOverride, flagBuildDir, "", "build-dir override - repo relative directory to run build target")
buildCmd.PersistentFlags().StringVar(&chainConfig.preBuildOverride, flagPreBuild, "", "pre-build override - command(s) to run prior to build-target")
buildCmd.PersistentFlags().StringVar(&chainConfig.preCloneOverride, flagPreClone, "", "pre-clone override - command(s) to run prior to repo clone")
buildCmd.PersistentFlags().StringVar(&chainConfig.buildTargetOverride, flagBuildTarget, "", "Build target (build-target) override")
buildCmd.PersistentFlags().StringVar(&chainConfig.buildEnvOverride, flagBuildEnv, "", "build-env override - Build environment variables")
buildCmd.PersistentFlags().StringVar(&chainConfig.binariesOverride, flagBinaries, "", "binaries override - Binaries after build phase to package into final image")
Expand Down
1 change: 1 addition & 0 deletions cmd/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func queueAndBuild(
GithubRepo: chainConfig.repoOverride,
Dockerfile: builder.DockerfileType(chainConfig.dockerfileOverride),
PreBuild: chainConfig.preBuildOverride,
PreClone: chainConfig.preCloneOverride,
BuildTarget: chainConfig.buildTargetOverride,
BuildEnv: strings.Split(chainConfig.buildEnvOverride, " "),
BuildDir: chainConfig.buildDirOverride,
Expand Down
4 changes: 4 additions & 0 deletions dockerfile/cosmos/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ RUN if [ "${TARGETARCH}" = "arm64" ] && [ "${BUILDARCH}" != "arm64" ]; then\
wget -c https://musl.cc/x86_64-linux-musl-cross.tgz -O - | tar -xzvv --strip-components 1 -C /usr;\
fi

ARG PRE_CLONE

RUN if [ ! -z "PRE_CLONE" ]; then sh -c "${PRE_CLONE}"; fi

ARG GITHUB_ORGANIZATION
ARG REPO_HOST

Expand Down

0 comments on commit 621cc41

Please sign in to comment.