Skip to content

Commit 86d4062

Browse files
committed
since we are using buildx we can move push/load logic to build.sh instead of using external release.sh
1 parent a58aa51 commit 86d4062

File tree

3 files changed

+18
-87
lines changed

3 files changed

+18
-87
lines changed

buildkite/src/Command/DockerImage.dhall

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,15 @@ let generateStep =
164164
}
165165
spec.size
166166

167+
let loadOnlyArg =
168+
if DockerPublish.shouldPublish
169+
spec.docker_publish
170+
spec.service
171+
172+
then ""
173+
174+
else " --load-only "
175+
167176
let buildDockerCmd =
168177
"./scripts/docker/build.sh"
169178
++ " --service ${Artifacts.dockerName spec.service}"
@@ -184,29 +193,7 @@ let generateStep =
184193
++ " --repo ${spec.repo}"
185194
++ " --platform ${Arch.platform spec.arch}"
186195
++ " --docker-registry ${DockerRepo.show spec.docker_repo}"
187-
188-
let releaseDockerCmd =
189-
if DockerPublish.shouldPublish
190-
spec.docker_publish
191-
spec.service
192-
193-
then "./scripts/docker/release.sh"
194-
++ " --service ${Artifacts.dockerName spec.service}"
195-
++ " --version ${spec.version}"
196-
++ " --network ${Network.lowerName spec.network}"
197-
++ " --deb-codename ${DebianVersions.lowerName
198-
spec.deb_codename}"
199-
++ " --deb-version ${spec.deb_version}"
200-
++ " --deb-profile ${Profiles.lowerName
201-
spec.deb_profile}"
202-
++ " --deb-build-flags ${BuildFlags.lowerName
203-
spec.build_flags}"
204-
++ " --platform ${Arch.platform spec.arch}"
205-
++ " --docker-registry ${DockerRepo.show
206-
spec.docker_repo}"
207-
208-
else " echo In order to ensure storage optimization, skipping publishing docker as this is not essential one or publishing is disabled . Docker publish setting is set to ${DockerPublish.show
209-
spec.docker_publish}."
196+
++ loadOnlyArg
210197

211198
let remoteRepoCmds =
212199
[ Cmd.run
@@ -215,7 +202,6 @@ let generateStep =
215202
++ " && "
216203
++ buildDockerCmd
217204
++ " && "
218-
++ releaseDockerCmd
219205
++ maybeVerify
220206
)
221207
]
@@ -237,7 +223,6 @@ let generateStep =
237223
++ " && "
238224
++ buildDockerCmd
239225
++ " && "
240-
++ releaseDockerCmd
241226
++ maybeStopDebianRepo
242227
++ maybeVerify
243228
)

scripts/docker/build.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,17 @@ function usage() {
3333
echo " --deb-build-flags The build-flags string for the debian package to install"
3434
echo " --deb-suffix The debian suffix to use for the docker image"
3535
echo " -p, --platform The target platform for the docker build (e.g. linux/amd64). Default=linux/amd64"
36+
echo " -l, --load-only Load the built image into local docker daemon only, do not push to remote registry"
3637
echo ""
3738
echo "Example: $0 --service faucet --version v0.1.0"
3839
echo "Valid Services: ${VALID_SERVICES[*]}"
3940
exit 1
4041
}
4142

43+
# Defines if build is for pushing to remote registry or loading locally only.
44+
# Can be overridden with --load-only flag.
45+
LOAD=""
46+
4247
while [[ "$#" -gt 0 ]]; do case $1 in
4348
-s|--service) SERVICE="$2"; shift;;
4449
-v|--version) VERSION="$2"; shift;;
@@ -47,6 +52,7 @@ while [[ "$#" -gt 0 ]]; do case $1 in
4752
-c|--cache-from) INPUT_CACHE="$2"; shift;;
4853
-r|--repo) MINA_REPO="$2"; shift;;
4954
-p|--platform) INPUT_PLATFORM="$2"; shift;;
55+
-l|--load-only) LOAD="--load" ;;
5056
--docker-registry) export DOCKER_REGISTRY="$2"; shift;;
5157
--no-cache) NO_CACHE="--no-cache"; ;;
5258
--deb-codename) INPUT_CODENAME="$2"; shift;;
@@ -254,9 +260,9 @@ BUILD_NETWORK="--allow=network.host"
254260
# If DOCKER_CONTEXT is not specified, assume none and just pipe the dockerfile into docker build
255261
if [[ -z "${DOCKER_CONTEXT}" ]]; then
256262
cat $DOCKERFILE_PATH | docker buildx build --network=host \
257-
--load --progress=plain $PLATFORM $DEBIAN_ARCH_ARG $CANONICAL_ARCH_ARG $DOCKER_REPO_ARG $NO_CACHE $BUILD_NETWORK $CACHE $NETWORK $IMAGE $DEB_CODENAME $DEB_RELEASE $DEB_VERSION $DOCKER_DEB_SUFFIX $DEB_REPO $BRANCH $REPO $LEGACY_VERSION -t "$TAG" -
263+
$LOAD --progress=plain $PLATFORM $DEBIAN_ARCH_ARG $CANONICAL_ARCH_ARG $DOCKER_REPO_ARG $NO_CACHE $BUILD_NETWORK $CACHE $NETWORK $IMAGE $DEB_CODENAME $DEB_RELEASE $DEB_VERSION $DOCKER_DEB_SUFFIX $DEB_REPO $BRANCH $REPO $LEGACY_VERSION -t "$TAG" -t "$HASHTAG" -
258264
else
259-
docker buildx build --load --network=host --progress=plain $PLATFORM $DEBIAN_ARCH_ARG $CANONICAL_ARCH_ARG $DOCKER_REPO_ARG $NO_CACHE $BUILD_NETWORK $CACHE $NETWORK $IMAGE $DEB_CODENAME $DEB_RELEASE $DEB_VERSION $DOCKER_DEB_SUFFIX $DEB_REPO $BRANCH $REPO $LEGACY_VERSION "$DOCKER_CONTEXT" -t "$TAG" -f $DOCKERFILE_PATH
265+
docker buildx build $LOAD --network=host --progress=plain $PLATFORM $DEBIAN_ARCH_ARG $CANONICAL_ARCH_ARG $DOCKER_REPO_ARG $NO_CACHE $BUILD_NETWORK $CACHE $NETWORK $IMAGE $DEB_CODENAME $DEB_RELEASE $DEB_VERSION $DOCKER_DEB_SUFFIX $DEB_REPO $BRANCH $REPO $LEGACY_VERSION "$DOCKER_CONTEXT" -t "$TAG" -t "$HASHTAG" -f $DOCKERFILE_PATH
260266
fi
261267

262268
echo "✅ Docker image for service ${SERVICE} built successfully."

scripts/docker/release.sh

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)