From 32d8613a8da04a7ceb0c2dba1ad23b95f582188d Mon Sep 17 00:00:00 2001 From: Hardik Gajjar Date: Fri, 7 Apr 2023 06:13:26 +0000 Subject: [PATCH 1/6] Split CLI image build to allow building CLI container only --- bin/command/build/baked/build.sh | 5 +++- bin/command/build/mount/build.sh | 3 ++ bin/sdk/images/baked.sh | 19 +++++++++++++ bin/sdk/images/common.sh | 48 +++++++++++++++++++------------- bin/sdk/images/mount.sh | 19 +++++++++++++ 5 files changed, 74 insertions(+), 20 deletions(-) diff --git a/bin/command/build/baked/build.sh b/bin/command/build/baked/build.sh index 28754a4be..d8f14e912 100644 --- a/bin/command/build/baked/build.sh +++ b/bin/command/build/baked/build.sh @@ -7,7 +7,7 @@ Registry::Help::command -c "build images" "[Deprecated for non-dev mode] Builds Registry::Help::command -c "build assets" "[Deprecated for non-dev mode] Builds assets." function Command::build() { - +set -ex Console::warn 'This command is deprecated for baked mount mode. Please, use up or export commands as well.' subCommand=${1} @@ -21,6 +21,9 @@ function Command::build() { Assets::build --force Images::buildFrontend --force ;; + cli) + Images::buildCli --force + ;; '') Images::buildApplication --force Assets::build --force diff --git a/bin/command/build/mount/build.sh b/bin/command/build/mount/build.sh index e37686ce5..f219264ab 100644 --- a/bin/command/build/mount/build.sh +++ b/bin/command/build/mount/build.sh @@ -16,6 +16,9 @@ function Command::build() { Assets::build Images::buildFrontend --force ;; + cli) + Images::buildCli --force + ;; codebase | code) Codebase::build --force ;; diff --git a/bin/sdk/images/baked.sh b/bin/sdk/images/baked.sh index a38ac6488..854d27b72 100644 --- a/bin/sdk/images/baked.sh +++ b/bin/sdk/images/baked.sh @@ -40,3 +40,22 @@ function Images::buildFrontend() { Images::_buildGateway Images::tagFrontend "${SPRYKER_DOCKER_TAG}" } + +function Images::buildCli() { + for arg in "${@}"; do + case "${arg}" in + '--force') + # it is always it. + ;; + '--no-cache') + # TODO implement --no-cache for build images + ;; + *) + Console::verbose "\nUnknown option ${INFO}${arg}${WARN} is acquired for Images::buildCli." + ;; + esac + done + + Images::_buildAppCli baked + Images::tagApplications "${SPRYKER_DOCKER_TAG}" +} \ No newline at end of file diff --git a/bin/sdk/images/common.sh b/bin/sdk/images/common.sh index 78226c887..8fcfa9fae 100644 --- a/bin/sdk/images/common.sh +++ b/bin/sdk/images/common.sh @@ -34,11 +34,7 @@ function Images::_buildApp() { local appImage="${SPRYKER_DOCKER_PREFIX}_app:${SPRYKER_DOCKER_TAG}" local localAppImage="${SPRYKER_DOCKER_PREFIX}_local_app:${SPRYKER_DOCKER_TAG}" local runtimeImage="${SPRYKER_DOCKER_PREFIX}_run_app:${SPRYKER_DOCKER_TAG}" - local baseCliImage="${SPRYKER_DOCKER_PREFIX}_base_cli:${SPRYKER_DOCKER_TAG}" - local cliImage="${SPRYKER_DOCKER_PREFIX}_cli:${SPRYKER_DOCKER_TAG}" - local pipelineImage="${SPRYKER_DOCKER_PREFIX}_pipeline:${SPRYKER_DOCKER_TAG}" - local runtimeCliImage="${SPRYKER_DOCKER_PREFIX}_run_cli:${SPRYKER_DOCKER_TAG}" - + if [ -n "${SSH_AUTH_SOCK_IN_CLI}" ]; then sshArgument=('--ssh' 'default') fi @@ -102,6 +98,33 @@ function Images::_buildApp() { "${DEPLOYMENT_PATH}/context" 1>&2 fi + Images::_buildAppCli ${folder} + + if [ "${withPushImages}" == "${TRUE}" ]; then + local jenkinsImage="${SPRYKER_DOCKER_PREFIX}_jenkins:${SPRYKER_DOCKER_TAG}" + + docker build \ + -t "${jenkinsImage}" \ + -f "${DEPLOYMENT_PATH}/images/common/services/jenkins/export/Dockerfile" \ + --progress="${PROGRESS_TYPE}" \ + --build-arg "SPRYKER_PARENT_IMAGE=${appImage}" \ + "${DEPLOYMENT_PATH}/" 1>&2 + fi + + Registry::Trap::releaseExitHook 'removeBuildSecrets' +} + +function Images::_buildAppCli() { + local -a sshArgument=() + local folder=${1} + local baseCliImage="${SPRYKER_DOCKER_PREFIX}_base_cli:${SPRYKER_DOCKER_TAG}" + local cliImage="${SPRYKER_DOCKER_PREFIX}_cli:${SPRYKER_DOCKER_TAG}" + local pipelineImage="${SPRYKER_DOCKER_PREFIX}_pipeline:${SPRYKER_DOCKER_TAG}" + local localAppImage="${SPRYKER_DOCKER_PREFIX}_local_app:${SPRYKER_DOCKER_TAG}" + local runtimeCliImage="${SPRYKER_DOCKER_PREFIX}_run_cli:${SPRYKER_DOCKER_TAG}" + + Images::_prepareSecrets + Console::verbose "${INFO}Building CLI images${NC}" docker build \ @@ -133,20 +156,7 @@ function Images::_buildApp() { --progress="${PROGRESS_TYPE}" \ --build-arg "SPRYKER_PARENT_IMAGE=${cliImage}" \ "${DEPLOYMENT_PATH}/context" 1>&2 - fi - - if [ "${withPushImages}" == "${TRUE}" ]; then - local jenkinsImage="${SPRYKER_DOCKER_PREFIX}_jenkins:${SPRYKER_DOCKER_TAG}" - - docker build \ - -t "${jenkinsImage}" \ - -f "${DEPLOYMENT_PATH}/images/common/services/jenkins/export/Dockerfile" \ - --progress="${PROGRESS_TYPE}" \ - --build-arg "SPRYKER_PARENT_IMAGE=${appImage}" \ - "${DEPLOYMENT_PATH}/" 1>&2 - fi - - Registry::Trap::releaseExitHook 'removeBuildSecrets' + fi } function Images::_buildFrontend() { diff --git a/bin/sdk/images/mount.sh b/bin/sdk/images/mount.sh index a9c047797..9f583aa5f 100644 --- a/bin/sdk/images/mount.sh +++ b/bin/sdk/images/mount.sh @@ -40,3 +40,22 @@ function Images::buildFrontend() { Images::_buildGateway Images::tagFrontend "${SPRYKER_DOCKER_TAG}" } + +function Images::buildCli() { + for arg in "${@}"; do + case "${arg}" in + '--force') + # it is always it. + ;; + '--no-cache') + # TODO implement --no-cache for build images + ;; + *) + Console::verbose "\nUnknown option ${INFO}${arg}${WARN} is acquired for Images::buildCli." + ;; + esac + done + + Images::_buildAppCli mount + Images::tagApplications "${SPRYKER_DOCKER_TAG}" +} \ No newline at end of file From 1c59213091381c632a3e06a1594592b66c932ff5 Mon Sep 17 00:00:00 2001 From: Hardik Gajjar Date: Fri, 7 Apr 2023 06:15:35 +0000 Subject: [PATCH 2/6] Fix debug code --- bin/command/build/baked/build.sh | 2 +- bin/sdk/images/baked.sh | 2 +- bin/sdk/images/mount.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/command/build/baked/build.sh b/bin/command/build/baked/build.sh index d8f14e912..6c15b0ae1 100644 --- a/bin/command/build/baked/build.sh +++ b/bin/command/build/baked/build.sh @@ -7,7 +7,7 @@ Registry::Help::command -c "build images" "[Deprecated for non-dev mode] Builds Registry::Help::command -c "build assets" "[Deprecated for non-dev mode] Builds assets." function Command::build() { -set -ex + Console::warn 'This command is deprecated for baked mount mode. Please, use up or export commands as well.' subCommand=${1} diff --git a/bin/sdk/images/baked.sh b/bin/sdk/images/baked.sh index 854d27b72..fcaf706b0 100644 --- a/bin/sdk/images/baked.sh +++ b/bin/sdk/images/baked.sh @@ -58,4 +58,4 @@ function Images::buildCli() { Images::_buildAppCli baked Images::tagApplications "${SPRYKER_DOCKER_TAG}" -} \ No newline at end of file +} diff --git a/bin/sdk/images/mount.sh b/bin/sdk/images/mount.sh index 9f583aa5f..8eb538c9b 100644 --- a/bin/sdk/images/mount.sh +++ b/bin/sdk/images/mount.sh @@ -58,4 +58,4 @@ function Images::buildCli() { Images::_buildAppCli mount Images::tagApplications "${SPRYKER_DOCKER_TAG}" -} \ No newline at end of file +} From b66e400e3a8bde882efd02b4b618364bd77ddd06 Mon Sep 17 00:00:00 2001 From: Hardik Gajjar Date: Mon, 10 Apr 2023 09:22:01 +0000 Subject: [PATCH 3/6] CLI build requires other base images too --- bin/command/build/baked/build.sh | 2 +- bin/command/build/mount/build.sh | 2 +- bin/sdk/images/baked.sh | 19 ------------------- bin/sdk/images/mount.sh | 19 ------------------- 4 files changed, 2 insertions(+), 40 deletions(-) diff --git a/bin/command/build/baked/build.sh b/bin/command/build/baked/build.sh index 6c15b0ae1..eecad18bd 100644 --- a/bin/command/build/baked/build.sh +++ b/bin/command/build/baked/build.sh @@ -22,7 +22,7 @@ function Command::build() { Images::buildFrontend --force ;; cli) - Images::buildCli --force + Images::buildApplication --force ;; '') Images::buildApplication --force diff --git a/bin/command/build/mount/build.sh b/bin/command/build/mount/build.sh index f219264ab..7c63ccec9 100644 --- a/bin/command/build/mount/build.sh +++ b/bin/command/build/mount/build.sh @@ -17,7 +17,7 @@ function Command::build() { Images::buildFrontend --force ;; cli) - Images::buildCli --force + Images::buildApplication --force ;; codebase | code) Codebase::build --force diff --git a/bin/sdk/images/baked.sh b/bin/sdk/images/baked.sh index fcaf706b0..a38ac6488 100644 --- a/bin/sdk/images/baked.sh +++ b/bin/sdk/images/baked.sh @@ -40,22 +40,3 @@ function Images::buildFrontend() { Images::_buildGateway Images::tagFrontend "${SPRYKER_DOCKER_TAG}" } - -function Images::buildCli() { - for arg in "${@}"; do - case "${arg}" in - '--force') - # it is always it. - ;; - '--no-cache') - # TODO implement --no-cache for build images - ;; - *) - Console::verbose "\nUnknown option ${INFO}${arg}${WARN} is acquired for Images::buildCli." - ;; - esac - done - - Images::_buildAppCli baked - Images::tagApplications "${SPRYKER_DOCKER_TAG}" -} diff --git a/bin/sdk/images/mount.sh b/bin/sdk/images/mount.sh index 8eb538c9b..a9c047797 100644 --- a/bin/sdk/images/mount.sh +++ b/bin/sdk/images/mount.sh @@ -40,22 +40,3 @@ function Images::buildFrontend() { Images::_buildGateway Images::tagFrontend "${SPRYKER_DOCKER_TAG}" } - -function Images::buildCli() { - for arg in "${@}"; do - case "${arg}" in - '--force') - # it is always it. - ;; - '--no-cache') - # TODO implement --no-cache for build images - ;; - *) - Console::verbose "\nUnknown option ${INFO}${arg}${WARN} is acquired for Images::buildCli." - ;; - esac - done - - Images::_buildAppCli mount - Images::tagApplications "${SPRYKER_DOCKER_TAG}" -} From b287341987544eb631c1a3d79583c2ffbc2c69ef Mon Sep 17 00:00:00 2001 From: Hardik Gajjar Date: Mon, 10 Apr 2023 09:23:56 +0000 Subject: [PATCH 4/6] Revert common.sh changes --- bin/sdk/images/common.sh | 50 ++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/bin/sdk/images/common.sh b/bin/sdk/images/common.sh index 8fcfa9fae..eb5d83001 100644 --- a/bin/sdk/images/common.sh +++ b/bin/sdk/images/common.sh @@ -34,7 +34,11 @@ function Images::_buildApp() { local appImage="${SPRYKER_DOCKER_PREFIX}_app:${SPRYKER_DOCKER_TAG}" local localAppImage="${SPRYKER_DOCKER_PREFIX}_local_app:${SPRYKER_DOCKER_TAG}" local runtimeImage="${SPRYKER_DOCKER_PREFIX}_run_app:${SPRYKER_DOCKER_TAG}" - + local baseCliImage="${SPRYKER_DOCKER_PREFIX}_base_cli:${SPRYKER_DOCKER_TAG}" + local cliImage="${SPRYKER_DOCKER_PREFIX}_cli:${SPRYKER_DOCKER_TAG}" + local pipelineImage="${SPRYKER_DOCKER_PREFIX}_pipeline:${SPRYKER_DOCKER_TAG}" + local runtimeCliImage="${SPRYKER_DOCKER_PREFIX}_run_cli:${SPRYKER_DOCKER_TAG}" + if [ -n "${SSH_AUTH_SOCK_IN_CLI}" ]; then sshArgument=('--ssh' 'default') fi @@ -98,33 +102,6 @@ function Images::_buildApp() { "${DEPLOYMENT_PATH}/context" 1>&2 fi - Images::_buildAppCli ${folder} - - if [ "${withPushImages}" == "${TRUE}" ]; then - local jenkinsImage="${SPRYKER_DOCKER_PREFIX}_jenkins:${SPRYKER_DOCKER_TAG}" - - docker build \ - -t "${jenkinsImage}" \ - -f "${DEPLOYMENT_PATH}/images/common/services/jenkins/export/Dockerfile" \ - --progress="${PROGRESS_TYPE}" \ - --build-arg "SPRYKER_PARENT_IMAGE=${appImage}" \ - "${DEPLOYMENT_PATH}/" 1>&2 - fi - - Registry::Trap::releaseExitHook 'removeBuildSecrets' -} - -function Images::_buildAppCli() { - local -a sshArgument=() - local folder=${1} - local baseCliImage="${SPRYKER_DOCKER_PREFIX}_base_cli:${SPRYKER_DOCKER_TAG}" - local cliImage="${SPRYKER_DOCKER_PREFIX}_cli:${SPRYKER_DOCKER_TAG}" - local pipelineImage="${SPRYKER_DOCKER_PREFIX}_pipeline:${SPRYKER_DOCKER_TAG}" - local localAppImage="${SPRYKER_DOCKER_PREFIX}_local_app:${SPRYKER_DOCKER_TAG}" - local runtimeCliImage="${SPRYKER_DOCKER_PREFIX}_run_cli:${SPRYKER_DOCKER_TAG}" - - Images::_prepareSecrets - Console::verbose "${INFO}Building CLI images${NC}" docker build \ @@ -156,7 +133,20 @@ function Images::_buildAppCli() { --progress="${PROGRESS_TYPE}" \ --build-arg "SPRYKER_PARENT_IMAGE=${cliImage}" \ "${DEPLOYMENT_PATH}/context" 1>&2 - fi + fi + + if [ "${withPushImages}" == "${TRUE}" ]; then + local jenkinsImage="${SPRYKER_DOCKER_PREFIX}_jenkins:${SPRYKER_DOCKER_TAG}" + + docker build \ + -t "${jenkinsImage}" \ + -f "${DEPLOYMENT_PATH}/images/common/services/jenkins/export/Dockerfile" \ + --progress="${PROGRESS_TYPE}" \ + --build-arg "SPRYKER_PARENT_IMAGE=${appImage}" \ + "${DEPLOYMENT_PATH}/" 1>&2 + fi + + Registry::Trap::releaseExitHook 'removeBuildSecrets' } function Images::_buildFrontend() { @@ -249,4 +239,4 @@ function Images::printAll() { printf "%s %s_frontend:%s\n" "frontend" "${SPRYKER_DOCKER_PREFIX}" "${tag}-frontend" printf "%s %s_pipeline:%s\n" "pipeline" "${SPRYKER_DOCKER_PREFIX}" "${tag}-pipeline" -} +} \ No newline at end of file From eefe4c07bfe94e9f7305594431161b7ec4b96bd4 Mon Sep 17 00:00:00 2001 From: Hardik Gajjar Date: Mon, 10 Apr 2023 09:24:48 +0000 Subject: [PATCH 5/6] Add empty line --- bin/sdk/images/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/sdk/images/common.sh b/bin/sdk/images/common.sh index eb5d83001..78226c887 100644 --- a/bin/sdk/images/common.sh +++ b/bin/sdk/images/common.sh @@ -239,4 +239,4 @@ function Images::printAll() { printf "%s %s_frontend:%s\n" "frontend" "${SPRYKER_DOCKER_PREFIX}" "${tag}-frontend" printf "%s %s_pipeline:%s\n" "pipeline" "${SPRYKER_DOCKER_PREFIX}" "${tag}-pipeline" -} \ No newline at end of file +} From aa423b76f259551f0520c62464ea42b0c0ae1658 Mon Sep 17 00:00:00 2001 From: Hardik Gajjar Date: Fri, 2 Feb 2024 19:06:05 +0530 Subject: [PATCH 6/6] Disable docker version check --- bin/environment/docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/environment/docker.sh b/bin/environment/docker.sh index 020e064a0..b41d30ebb 100644 --- a/bin/environment/docker.sh +++ b/bin/environment/docker.sh @@ -117,4 +117,4 @@ function Environment::getFullUserId() { return "${TRUE}" } -Registry::addChecker 'Environment::checkDockerVersion' +#Registry::addChecker 'Environment::checkDockerVersion'