mirror of
https://github.com/ChristianLight/tutor.git
synced 2024-12-04 19:03:39 +00:00
fix: improve support of non-buildkit Docker build
See comment here: https://github.com/overhangio/tutor/pull/868#issuecomment-1640429396 See also the conversation that spawned this PR: https://discuss.openedx.org/t/issue-in-tutor-palm-release-with-tuotr-dev-launch-while-installing/10629
This commit is contained in:
parent
ef30dbc193
commit
67009fb857
@ -0,0 +1,4 @@
|
||||
- [Improvement] Improve support of legacy non-BuildKit mode: (by @regisb)
|
||||
- [Bugfix] Fix building of openedx Docker image.
|
||||
- [Improvement] Remove `--cache-from` build option.
|
||||
- [Improvement] Add a warning concerning the lack of support of the `--build-context` option.
|
@ -147,7 +147,6 @@ class ImagesTests(PluginsTestCase, TestCommandMixin):
|
||||
"--target",
|
||||
"target",
|
||||
"docker_args",
|
||||
"--cache-from=type=registry,ref=service1:1.0.0-cache",
|
||||
],
|
||||
list(image_build.call_args[0][1:]),
|
||||
)
|
||||
|
@ -223,16 +223,27 @@ def build(
|
||||
image_build_args = [*command_args, *custom_args]
|
||||
|
||||
# Registry cache
|
||||
if not no_registry_cache:
|
||||
image_build_args.append(f"--cache-from=type=registry,ref={tag}-cache")
|
||||
if cache_to_registry:
|
||||
image_build_args.append(
|
||||
f"--cache-to=type=registry,mode=max,ref={tag}-cache"
|
||||
)
|
||||
if utils.is_buildkit_enabled():
|
||||
if not no_registry_cache:
|
||||
image_build_args.append(
|
||||
f"--cache-from=type=registry,ref={tag}-cache"
|
||||
)
|
||||
if cache_to_registry:
|
||||
image_build_args.append(
|
||||
f"--cache-to=type=registry,mode=max,ref={tag}-cache"
|
||||
)
|
||||
|
||||
# Build contexts
|
||||
for host_path, stage_name in build_contexts.get(name, []):
|
||||
image_build_args.append(f"--build-context={stage_name}={host_path}")
|
||||
if utils.is_buildkit_enabled():
|
||||
fmt.echo_info(
|
||||
f"Adding {host_path} to the build context '{stage_name}' of image '{image}'"
|
||||
)
|
||||
image_build_args.append(f"--build-context={stage_name}={host_path}")
|
||||
else:
|
||||
fmt.echo_alert(
|
||||
f"Unable to add {host_path} to the build context '{stage_name}' of image '{host_path}' because BuildKit is disabled."
|
||||
)
|
||||
|
||||
# Build
|
||||
images.build(
|
||||
@ -257,9 +268,6 @@ def get_image_build_contexts(config: Config) -> dict[str, list[tuple[str, str]]]
|
||||
for image_name, stage_name in hooks.Filters.IMAGES_BUILD_MOUNTS.iterate(
|
||||
user_mount
|
||||
):
|
||||
fmt.echo_info(
|
||||
f"Adding {user_mount} to the build context '{stage_name}' of image '{image_name}'"
|
||||
)
|
||||
if image_name not in build_contexts:
|
||||
build_contexts[image_name] = []
|
||||
build_contexts[image_name].append((user_mount, stage_name))
|
||||
|
@ -89,6 +89,9 @@ RUN {% if is_buildkit_enabled() %}--mount=type=cache,target=/openedx/.cache/pip,
|
||||
setuptools==67.6.1 pip==23.0.1. wheel==0.40.0
|
||||
|
||||
# Install base requirements
|
||||
{% if not is_buildkit_enabled() %}
|
||||
COPY --from=edx-platform /requirements/edx/base.txt /openedx/edx-platform/requirements/edx/base.txt
|
||||
{% endif %}
|
||||
RUN {% if is_buildkit_enabled() %}--mount=type=bind,from=edx-platform,source=/requirements/edx/base.txt,target=/openedx/edx-platform/requirements/edx/base.txt \
|
||||
--mount=type=cache,target=/openedx/.cache/pip,sharing=shared {% endif %}pip install -r /openedx/edx-platform/requirements/edx/base.txt
|
||||
|
||||
@ -123,6 +126,10 @@ RUN nodeenv /openedx/nodeenv --node=16.14.0 --prebuilt
|
||||
# Install nodejs requirements
|
||||
ARG NPM_REGISTRY={{ NPM_REGISTRY }}
|
||||
WORKDIR /openedx/edx-platform
|
||||
{% if not is_buildkit_enabled() %}
|
||||
COPY --from=edx-platform /package.json /openedx/edx-platform/package.json
|
||||
COPY --from=edx-platform /package-lock.json /openedx/edx-platform/package-lock.json
|
||||
{% endif %}
|
||||
RUN {% if is_buildkit_enabled() %}--mount=type=bind,from=edx-platform,source=/package.json,target=/openedx/edx-platform/package.json \
|
||||
--mount=type=bind,from=edx-platform,source=/package-lock.json,target=/openedx/edx-platform/package-lock.json \
|
||||
--mount=type=cache,target=/root/.npm,sharing=shared {% endif %}npm clean-install --no-audit --registry=$NPM_REGISTRY
|
||||
|
Loading…
Reference in New Issue
Block a user