Skip to content

Commit

Permalink
FIX: layer: skip load remote cache to avoid docker crash bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-js committed Jun 7, 2022
1 parent 9b9dfa4 commit a23538a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion source/debian11/BUILD_FLAVOR_MAP.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"FLAVOR_BIN_COMMON": { "NAME": "bin-common", "BASE_IMAGE": "node", "LAYER_SCRIPT": "3-0-bin-common.sh" },
"FLAVOR_DEP_BUILD": { "NAME": "dep-build", "BASE_IMAGE": "bin-common", "LAYER_SCRIPT": "3-00-dep-build.sh" },
"FLAVOR_BIN_SSHD": { "NAME": "bin-sshd", "BASE_IMAGE": "bin-common", "LAYER_SCRIPT": "3-1-bin-sshd.sh" },
"FLAVOR_BIN_NGINX": { "NAME": "bin-nginx", "BASE_IMAGE": "bin-sshd", "LAYER_SCRIPT": "3-2-bin-nginx-check.sh", "LAYER_DEP_BUILD_SCRIPT": "3-2-bin-nginx-dep-build.sh", "DEP_BUILD_COPY": "/usr/local/bin/nginx", "DEP_BUILD_PURE": true },
"FLAVOR_BIN_NGINX": { "NAME": "bin-nginx", "BASE_IMAGE": "bin-sshd", "LAYER_SCRIPT": "3-2-bin-nginx-check.sh", "LAYER_DEP_BUILD_SCRIPT": "3-2-bin-nginx-dep-build.sh", "DEP_BUILD_COPY": "/usr/local/bin/nginx" },
"FLAVOR_BIN_GIT": { "NAME": "bin-git", "BASE_IMAGE": "bin-nginx", "LAYER_SCRIPT": "3-3-bin-git.sh" },
"FLAVOR_BIN_ETC": { "NAME": "bin-etc", "BASE_IMAGE": "bin-git", "LAYER_SCRIPT": "3-9-bin-etc.sh" },

Expand Down
11 changes: 7 additions & 4 deletions source/debian11/build-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,13 @@ runKit(async (kit) => {
'image', 'build',
`--tag=${getFlavoredImageTag(BUILD_FLAVOR.NAME)}-${DOCKER_BUILD_ARCH_INFO.key}`,
`--tag=${getFlavoredImageTag(BUILD_FLAVOR.NAME, TAG_LAYER_CACHE)}-${DOCKER_BUILD_ARCH_INFO.key}`, // NOTE: for layer to use as base, so version-bump won't change Dockerfile
`--cache-from=${[ ...new Set([ // cache tag
`${getFlavoredImageTag(BUILD_FLAVOR.NAME, TAG_LAYER_CACHE)}-${DOCKER_BUILD_ARCH_INFO.key}`, // try same label first
`${getFlavoredImageTag(BUILD_FLAVOR.NAME, TAG_LAYER_MAIN_CACHE)}-${DOCKER_BUILD_ARCH_INFO.key}` // try `main` next
]) ].join(',')}`, // https://github.com/moby/moby/issues/34715#issuecomment-425933774
// TODO: disable for now. a loop in cache may stack-overflow dockerd (buildkit), possibly related:
// https://github.com/moby/buildkit/issues/1902
// https://github.com/moby/moby/issues/40993#issuecomment-634259286
// `--cache-from=${[ ...new Set([ // cache tag
// `${getFlavoredImageTag(BUILD_FLAVOR.NAME, TAG_LAYER_CACHE)}-${DOCKER_BUILD_ARCH_INFO.key}`, // try same label first
// `${getFlavoredImageTag(BUILD_FLAVOR.NAME, TAG_LAYER_MAIN_CACHE)}-${DOCKER_BUILD_ARCH_INFO.key}` // try `main` next
// ]) ].join(',')}`, // https://github.com/moby/moby/issues/34715#issuecomment-425933774
'--build-arg=BUILDKIT_INLINE_CACHE=1', // save build cache metadata // https://docs.docker.com/engine/reference/commandline/build/#specifying-external-cache-sources
`--file=./Dockerfile.${DOCKER_BUILD_ARCH_INFO.key}`,
`--platform=${DOCKER_BUILD_ARCH_INFO.docker}`,
Expand Down

0 comments on commit a23538a

Please sign in to comment.