-
Notifications
You must be signed in to change notification settings - Fork 122
NO-JIRA: refactor(jupyter/*/Dockerfile*): wrap multiple RUN commands with bash for improved readability and error handling #2655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,10 +16,13 @@ FROM registry.access.redhat.com/ubi9/go-toolset:latest AS mongocli-builder | |||||||||||||||||||||||||||||
| ARG MONGOCLI_VERSION=2.0.4 | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| WORKDIR /tmp/ | ||||||||||||||||||||||||||||||
| RUN curl -Lo mongodb-cli-mongocli-v${MONGOCLI_VERSION}.zip https://github.com/mongodb/mongodb-cli/archive/refs/tags/mongocli/v${MONGOCLI_VERSION}.zip | ||||||||||||||||||||||||||||||
| RUN unzip ./mongodb-cli-mongocli-v${MONGOCLI_VERSION}.zip | ||||||||||||||||||||||||||||||
| RUN cd ./mongodb-cli-mongocli-v${MONGOCLI_VERSION}/ && \ | ||||||||||||||||||||||||||||||
| CGO_ENABLED=1 GOOS=linux go build -a -tags strictfipsruntime -o /tmp/mongocli ./cmd/mongocli/ | ||||||||||||||||||||||||||||||
| RUN /bin/bash <<'EOF' | ||||||||||||||||||||||||||||||
| set -Eeuxo pipefail | ||||||||||||||||||||||||||||||
| curl -Lo mongodb-cli-mongocli-v${MONGOCLI_VERSION}.zip https://github.com/mongodb/mongodb-cli/archive/refs/tags/mongocli/v${MONGOCLI_VERSION}.zip | ||||||||||||||||||||||||||||||
| unzip ./mongodb-cli-mongocli-v${MONGOCLI_VERSION}.zip | ||||||||||||||||||||||||||||||
| cd ./mongodb-cli-mongocli-v${MONGOCLI_VERSION}/ | ||||||||||||||||||||||||||||||
| CGO_ENABLED=1 GOOS=linux go build -a -tags strictfipsruntime -o /tmp/mongocli ./cmd/mongocli/ | ||||||||||||||||||||||||||||||
| EOF | ||||||||||||||||||||||||||||||
|
Comment on lines
+19
to
+25
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: HEREDOC single-quoted delimiter prevents variable expansion. The mongocli-builder stage uses This issue affects all four Dockerfiles in this PR at the mongocli-builder stage and potentially other stages using variables. Apply this fix to enable variable expansion: -RUN /bin/bash <<'EOF'
+RUN /bin/bash <<EOF
set -Eeuxo pipefail
curl -Lo mongodb-cli-mongocli-v${MONGOCLI_VERSION}.zip https://github.com/mongodb/mongodb-cli/archive/refs/tags/mongocli/v${MONGOCLI_VERSION}.zip
unzip ./mongodb-cli-mongocli-v${MONGOCLI_VERSION}.zip
cd ./mongodb-cli-mongocli-v${MONGOCLI_VERSION}/
CGO_ENABLED=1 GOOS=linux go build -a -tags strictfipsruntime -o /tmp/mongocli ./cmd/mongocli/
-EOF
+EOFNote: Unquoted 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, that is not how this works, this is Dockerfile heredoc, not Bash heredoc
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query: Error during web search @jiridanek, you're absolutely right, and I apologize for the incorrect analysis. In Dockerfile HEREDOCs, Docker expands So your code is correct as written— Thank you for the correction! ✏️ Learnings added
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| #################### | ||||||||||||||||||||||||||||||
| # cuda-base # | ||||||||||||||||||||||||||||||
|
|
@@ -49,7 +52,12 @@ EOF | |||||||||||||||||||||||||||||
| # upgrade first to avoid fixable vulnerabilities end | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # Install useful OS packages | ||||||||||||||||||||||||||||||
| RUN dnf install -y perl mesa-libGL skopeo && dnf clean all && rm -rf /var/cache/yum | ||||||||||||||||||||||||||||||
| RUN /bin/bash <<'EOF' | ||||||||||||||||||||||||||||||
| set -Eeuxo pipefail | ||||||||||||||||||||||||||||||
| dnf install -y perl mesa-libGL skopeo | ||||||||||||||||||||||||||||||
| dnf clean all | ||||||||||||||||||||||||||||||
| rm -rf /var/cache/yum | ||||||||||||||||||||||||||||||
| EOF | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # Other apps and tools installed as default user | ||||||||||||||||||||||||||||||
| USER 1001 | ||||||||||||||||||||||||||||||
|
|
@@ -110,7 +118,12 @@ WORKDIR /opt/app-root/bin | |||||||||||||||||||||||||||||
| USER root | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # Install useful OS packages | ||||||||||||||||||||||||||||||
| RUN dnf install -y jq unixODBC postgresql git-lfs libsndfile libxcrypt-compat && dnf clean all && rm -rf /var/cache/yum | ||||||||||||||||||||||||||||||
| RUN /bin/bash <<'EOF' | ||||||||||||||||||||||||||||||
| set -Eeuxo pipefail | ||||||||||||||||||||||||||||||
| dnf install -y jq unixODBC postgresql git-lfs libsndfile libxcrypt-compat | ||||||||||||||||||||||||||||||
| dnf clean all | ||||||||||||||||||||||||||||||
| rm -rf /var/cache/yum | ||||||||||||||||||||||||||||||
| EOF | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # Copy dynamically-linked mongocli built in earlier build stage | ||||||||||||||||||||||||||||||
| COPY --from=mongocli-builder /tmp/mongocli /opt/app-root/bin/ | ||||||||||||||||||||||||||||||
|
|
@@ -146,24 +159,27 @@ LABEL name="odh-notebook-jupyter-cuda-pytorch-ubi9-python-3.12" \ | |||||||||||||||||||||||||||||
| # Install Python packages and Jupyterlab extensions from requirements.txt | ||||||||||||||||||||||||||||||
| COPY ${PYTORCH_SOURCE_CODE}/pylock.toml ./ | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| RUN echo "Installing softwares and packages" && \ | ||||||||||||||||||||||||||||||
| # This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`, | ||||||||||||||||||||||||||||||
| # we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common. | ||||||||||||||||||||||||||||||
| uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./pylock.toml && \ | ||||||||||||||||||||||||||||||
| # setup path for runtime configuration | ||||||||||||||||||||||||||||||
| mkdir /opt/app-root/runtimes && \ | ||||||||||||||||||||||||||||||
| # Remove default Elyra runtime-images \ | ||||||||||||||||||||||||||||||
| rm /opt/app-root/share/jupyter/metadata/runtime-images/*.json && \ | ||||||||||||||||||||||||||||||
| # Replace Notebook's launcher, "(ipykernel)" with Python's version 3.x.y \ | ||||||||||||||||||||||||||||||
| sed -i -e "s/Python.*/$(python --version | cut -d '.' -f-2)\",/" /opt/app-root/share/jupyter/kernels/python3/kernel.json && \ | ||||||||||||||||||||||||||||||
| # copy jupyter configuration | ||||||||||||||||||||||||||||||
| cp /opt/app-root/bin/utils/jupyter_server_config.py /opt/app-root/etc/jupyter && \ | ||||||||||||||||||||||||||||||
| # Disable announcement plugin of jupyterlab \ | ||||||||||||||||||||||||||||||
| jupyter labextension disable "@jupyterlab/apputils-extension:announcements" && \ | ||||||||||||||||||||||||||||||
| # Apply JupyterLab addons \ | ||||||||||||||||||||||||||||||
| /opt/app-root/bin/utils/addons/apply.sh && \ | ||||||||||||||||||||||||||||||
| # Fix permissions to support pip in Openshift environments \ | ||||||||||||||||||||||||||||||
| chmod -R g+w /opt/app-root/lib/python3.12/site-packages && \ | ||||||||||||||||||||||||||||||
| fix-permissions /opt/app-root -P | ||||||||||||||||||||||||||||||
| RUN /bin/bash <<'EOF' | ||||||||||||||||||||||||||||||
| set -Eeuxo pipefail | ||||||||||||||||||||||||||||||
| echo "Installing softwares and packages" | ||||||||||||||||||||||||||||||
| # This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`, | ||||||||||||||||||||||||||||||
| # we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common. | ||||||||||||||||||||||||||||||
| uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./pylock.toml | ||||||||||||||||||||||||||||||
| # setup path for runtime configuration | ||||||||||||||||||||||||||||||
| mkdir /opt/app-root/runtimes | ||||||||||||||||||||||||||||||
| # Remove default Elyra runtime-images | ||||||||||||||||||||||||||||||
| rm /opt/app-root/share/jupyter/metadata/runtime-images/*.json | ||||||||||||||||||||||||||||||
| # Replace Notebook's launcher, "(ipykernel)" with Python's version 3.x.y | ||||||||||||||||||||||||||||||
| sed -i -e "s/Python.*/$(python --version | cut -d '.' -f-2)\",/" /opt/app-root/share/jupyter/kernels/python3/kernel.json | ||||||||||||||||||||||||||||||
| # copy jupyter configuration | ||||||||||||||||||||||||||||||
| cp /opt/app-root/bin/utils/jupyter_server_config.py /opt/app-root/etc/jupyter | ||||||||||||||||||||||||||||||
| # Disable announcement plugin of jupyterlab | ||||||||||||||||||||||||||||||
| jupyter labextension disable "@jupyterlab/apputils-extension:announcements" | ||||||||||||||||||||||||||||||
| # Apply JupyterLab addons | ||||||||||||||||||||||||||||||
| /opt/app-root/bin/utils/addons/apply.sh | ||||||||||||||||||||||||||||||
| # Fix permissions to support pip in Openshift environments | ||||||||||||||||||||||||||||||
| chmod -R g+w /opt/app-root/lib/python3.12/site-packages | ||||||||||||||||||||||||||||||
| fix-permissions /opt/app-root -P | ||||||||||||||||||||||||||||||
| EOF | ||||||||||||||||||||||||||||||
|
Comment on lines
+162
to
+183
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: HEREDOC single quotes prevent Line 173 uses Change to unquoted -RUN /bin/bash <<'EOF'
+RUN /bin/bash <<EOF
set -Eeuxo pipefail
echo "Installing softwares and packages"
# This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
# we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./pylock.toml
# setup path for runtime configuration
mkdir /opt/app-root/runtimes
# Remove default Elyra runtime-images
rm /opt/app-root/share/jupyter/metadata/runtime-images/*.json
# Replace Notebook's launcher, "(ipykernel)" with Python's version 3.x.y
sed -i -e "s/Python.*/$(python --version | cut -d '.' -f-2)\",/" /opt/app-root/share/jupyter/kernels/python3/kernel.json
# copy jupyter configuration
cp /opt/app-root/bin/utils/jupyter_server_config.py /opt/app-root/etc/jupyter
# Disable announcement plugin of jupyterlab
jupyter labextension disable "@jupyterlab/apputils-extension:announcements"
# Apply JupyterLab addons
/opt/app-root/bin/utils/addons/apply.sh
# Fix permissions to support pip in Openshift environments
chmod -R g+w /opt/app-root/lib/python3.12/site-packages
fix-permissions /opt/app-root -P
-EOF
+EOF🤖 Prompt for AI Agents
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, that is not how this works, this is Dockerfile heredoc, not Bash heredoc
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query: 💡 Result: Short answer: quoting the heredoc delimiter in a Dockerfile (e.g. <<'EOF' or <<"EOF") disables here-doc expansion; an unquoted delimiter (<<EOF) allows parameter/command/arithmetic expansion and backslash-newline handling. Also use <<-EOF to strip leading tabs. See Docker's docs and standard shell heredoc rules. [1][2] Examples:
References:
@jiridanek You're absolutely right, and I apologize for the confusion! In Dockerfile heredocs, the quoted delimiter So Thank you for the correction! ✏️ Learnings added
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| WORKDIR /opt/app-root/src | ||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,10 +14,13 @@ FROM registry.access.redhat.com/ubi9/go-toolset:latest AS mongocli-builder | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ARG MONGOCLI_VERSION=2.0.4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| WORKDIR /tmp/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RUN curl -Lo mongodb-cli-mongocli-v${MONGOCLI_VERSION}.zip https://github.com/mongodb/mongodb-cli/archive/refs/tags/mongocli/v${MONGOCLI_VERSION}.zip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RUN unzip ./mongodb-cli-mongocli-v${MONGOCLI_VERSION}.zip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RUN cd ./mongodb-cli-mongocli-v${MONGOCLI_VERSION}/ && \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CGO_ENABLED=1 GOOS=linux go build -a -tags strictfipsruntime -o /tmp/mongocli ./cmd/mongocli/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RUN /bin/bash <<'EOF' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set -Eeuxo pipefail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| curl -Lo mongodb-cli-mongocli-v${MONGOCLI_VERSION}.zip https://github.com/mongodb/mongodb-cli/archive/refs/tags/mongocli/v${MONGOCLI_VERSION}.zip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| unzip ./mongodb-cli-mongocli-v${MONGOCLI_VERSION}.zip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cd ./mongodb-cli-mongocli-v${MONGOCLI_VERSION}/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CGO_ENABLED=1 GOOS=linux go build -a -tags strictfipsruntime -o /tmp/mongocli ./cmd/mongocli/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| EOF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # rocm-base # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -47,7 +50,12 @@ EOF | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # upgrade first to avoid fixable vulnerabilities end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Install useful OS packages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RUN dnf install -y perl mesa-libGL skopeo && dnf clean all && rm -rf /var/cache/yum | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RUN /bin/bash <<'EOF' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set -Eeuxo pipefail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dnf install -y perl mesa-libGL skopeo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dnf clean all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rm -rf /var/cache/yum | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| EOF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Other apps and tools installed as default user | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| USER 1001 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -108,7 +116,12 @@ WORKDIR /opt/app-root/bin | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| USER root | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Install useful OS packages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RUN dnf install -y jq unixODBC postgresql git-lfs libsndfile && dnf clean all && rm -rf /var/cache/yum | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RUN /bin/bash <<'EOF' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set -Eeuxo pipefail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dnf install -y jq unixODBC postgresql git-lfs libsndfile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dnf clean all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rm -rf /var/cache/yum | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| EOF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Copy dynamically-linked mongocli built in earlier build stage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| COPY --from=mongocli-builder /tmp/mongocli /opt/app-root/bin/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -144,26 +157,29 @@ LABEL name="odh-notebook-jupyter-rocm-tensorflow-ubi9-python-3.12" \ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| COPY ${TENSORFLOW_SOURCE_CODE}/pylock.toml ./ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RUN echo "Installing softwares and packages" && \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Not using --build-constraints=./requirements.txt because error: Unnamed requirements are not allowed as constraints (found: `https://repo.radeon.com/rocm/manylinux/rocm-rel-6.4/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./pylock.toml && \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # setup path for runtime configuration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mkdir /opt/app-root/runtimes && \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Remove default Elyra runtime-images \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rm /opt/app-root/share/jupyter/metadata/runtime-images/*.json && \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Replace Notebook's launcher, "(ipykernel)" with Python's version 3.x.y \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sed -i -e "s/Python.*/$(python --version | cut -d '.' -f-2)\",/" /opt/app-root/share/jupyter/kernels/python3/kernel.json && \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # copy jupyter configuration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cp /opt/app-root/bin/utils/jupyter_server_config.py /opt/app-root/etc/jupyter && \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Disable announcement plugin of jupyterlab \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| jupyter labextension disable "@jupyterlab/apputils-extension:announcements" && \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Apply JupyterLab addons \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /opt/app-root/bin/utils/addons/apply.sh && \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Fix permissions to support pip in Openshift environments \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| chmod -R g+w /opt/app-root/lib/python3.12/site-packages && \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fix-permissions /opt/app-root -P | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RUN /bin/bash <<'EOF' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set -Eeuxo pipefail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Installing softwares and packages" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Not using --build-constraints=./requirements.txt because error: Unnamed requirements are not allowed as constraints (found: `https://repo.radeon.com/rocm/manylinux/rocm-rel-6.4/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./pylock.toml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # setup path for runtime configuration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mkdir /opt/app-root/runtimes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Remove default Elyra runtime-images | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rm /opt/app-root/share/jupyter/metadata/runtime-images/*.json | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Replace Notebook's launcher, "(ipykernel)" with Python's version 3.x.y | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sed -i -e "s/Python.*/$(python --version | cut -d '.' -f-2)\",/" /opt/app-root/share/jupyter/kernels/python3/kernel.json | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # copy jupyter configuration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cp /opt/app-root/bin/utils/jupyter_server_config.py /opt/app-root/etc/jupyter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Disable announcement plugin of jupyterlab | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| jupyter labextension disable "@jupyterlab/apputils-extension:announcements" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Apply JupyterLab addons | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /opt/app-root/bin/utils/addons/apply.sh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Fix permissions to support pip in Openshift environments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| chmod -R g+w /opt/app-root/lib/python3.12/site-packages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fix-permissions /opt/app-root -P | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| EOF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+160
to
+182
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Heredoc with single-quoted delimiter prevents bash command substitution on line 172. Line 172 contains This means the sed command will receive the literal string Change the heredoc delimiter from -RUN /bin/bash <<'EOF'
+RUN /bin/bash <<EOF
set -Eeuxo pipefail
echo "Installing softwares and packages"
# This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
# we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
# Not using --build-constraints=./requirements.txt because error: Unnamed requirements are not allowed as constraints (found: `https://repo.radeon.com/rocm/manylinux/rocm-rel-6.4/
uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./pylock.toml
# setup path for runtime configuration
mkdir /opt/app-root/runtimes
# Remove default Elyra runtime-images
rm /opt/app-root/share/jupyter/metadata/runtime-images/*.json
# Replace Notebook's launcher, "(ipykernel)" with Python's version 3.x.y
sed -i -e "s/Python.*/$(python --version | cut -d '.' -f-2)\",/" /opt/app-root/share/jupyter/kernels/python3/kernel.json
# copy jupyter configuration
cp /opt/app-root/bin/utils/jupyter_server_config.py /opt/app-root/etc/jupyter
# Disable announcement plugin of jupyterlab
jupyter labextension disable "@jupyterlab/apputils-extension:announcements"
# Apply JupyterLab addons
/opt/app-root/bin/utils/addons/apply.sh
# Fix permissions to support pip in Openshift environments
chmod -R g+w /opt/app-root/lib/python3.12/site-packages
fix-permissions /opt/app-root -P
EOFAlternatively, use double quotes: 📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsCritical: Heredoc with single-quoted delimiter prevents bash command substitution on line 172. Line 172 contains Change the heredoc delimiter to allow command substitution: -RUN /bin/bash <<'EOF'
+RUN /bin/bash <<EOF
set -Eeuxo pipefail
echo "Installing softwares and packages"
# This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
# we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
# Not using --build-constraints=./requirements.txt because error: Unnamed requirements are not allowed as constraints (found: `https://repo.radeon.com/rocm/manylinux/rocm-rel-6.4/
uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./pylock.toml
# setup path for runtime configuration
mkdir /opt/app-root/runtimes
# Remove default Elyra runtime-images
rm /opt/app-root/share/jupyter/metadata/runtime-images/*.json
# Replace Notebook's launcher, "(ipykernel)" with Python's version 3.x.y
sed -i -e "s/Python.*/$(python --version | cut -d '.' -f-2)\",/" /opt/app-root/share/jupyter/kernels/python3/kernel.json
# copy jupyter configuration
cp /opt/app-root/bin/utils/jupyter_server_config.py /opt/app-root/etc/jupyter
# Disable announcement plugin of jupyterlab
jupyter labextension disable "@jupyterlab/apputils-extension:announcements"
# Apply JupyterLab addons
/opt/app-root/bin/utils/addons/apply.sh
# Fix permissions to support pip in Openshift environments
chmod -R g+w /opt/app-root/lib/python3.12/site-packages
fix-permissions /opt/app-root -P
EOF📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, that is not how this works, this is Dockerfile heredoc, not Bash heredoc
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: Length of output: 0 🌐 Web query: 💡 Result: Short answer: quote the heredoc delimiter with single quotes (<<'EOF') to prevent variable and command expansion; leave it unquoted (<<EOF) to have expansion happen at Dockerfile/build time. Example:
References: Dockerfile heredoc behavior and examples. [1][2] @jiridanek You're absolutely right, and I apologize for the incorrect analysis! I confused Dockerfile HEREDOC behavior with bash heredoc behavior. In Dockerfile HEREDOCs:
However, in both cases, the content is passed to the bash shell for execution, and bash will still perform its own command substitution on So your code is correct as-is: RUN /bin/bash <<'EOF'
sed -i -e "s/Python.*/$(python --version | cut -d '.' -f-2)\",/" /opt/app-root/share/jupyter/kernels/python3/kernel.json
EOFThe My previous comments were incorrect and should be disregarded. Thank you for the correction! |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| COPY ${JUPYTER_REUSABLE_UTILS}/usercustomize.pth ${JUPYTER_REUSABLE_UTILS}/monkey_patch_protobuf_6x.py /opt/app-root/lib/python3.12/site-packages/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Critical: Variable substitution broken in quoted heredoc.
The heredoc uses
<<'EOF'(with single quotes around EOF), which prevents variable expansion. However, line 21 uses${MONGOCLI_VERSION}, which will not be substituted—the literal string${MONGOCLI_VERSION}will be passed to curl, causing a malformed URL and build failure.Fix by using unquoted heredoc delimiter:
Note: Unquoted heredocs allow variable expansion but also allow command substitution. Verify that no user input or untrusted data is interpolated.
🏁 Script executed:
Length of output: 733
🏁 Script executed:
Length of output: 1010
🏁 Script executed:
Length of output: 617
🏁 Script executed:
Length of output: 196
🏁 Script executed:
Length of output: 5424
🏁 Script executed:
Length of output: 579
🏁 Script executed:
Length of output: 515
🏁 Script executed:
Length of output: 37
🌐 Web query:
💡 Result:
Short answer: quoting the heredoc delimiter (e.g. <<'EOF') disables shell-style expansion inside the here‑document. In Dockerfiles that means the builder will not expand variables at parse/build time; the content is kept literal and any expansion (if any) happens later when the shell inside the image runs the script. If the delimiter is unquoted (<<EOF) the builder performs parameter/command/arithmetic expansion on the here-doc content. [1][2][3]
Example — build-time expansion (unquoted):
RUN <<EOF
echo "$FOO"
EOF
If FOO is an ARG/ENV known to the builder, it will be expanded during build and the built RUN receives the expanded text. [1]
Example — literal (quoted delimiter):
RUN <<'EOF'
echo "$FOO"
EOF
The here-doc is kept literal (no expansion by the builder); $FOO will be expanded only at runtime by the shell inside the container (if that shell does expansion). [1][2]
References:
🌐 Web query:
💡 Result:
Short answer: quoting the heredoc delimiter (e.g. <<'EOF') prevents shell/Dockerfile-time expansion, so ARG values will not be substituted; leaving it unquoted (<<EOF) lets the shell expand $VAR (and Docker injects ARG into the environment for RUN/COPY). See examples below.
Why: heredoc quoting is a shell rule — if the delimiter is quoted, the heredoc body is taken literally (no parameter/command/arithmetic expansion). Docker passes ARGs into the build environment, but expansion inside a RUN heredoc is done by the shell that executes RUN. Quoting the delimiter disables that shell expansion (and for COPY heredocs Docker also documents that a quoted delimiter prevents build-time expansion). (stackoverflow.com)
Examples
expands ARG:
ARG MY=world
RUN cat </tmp/x
hello $MY
EOF
-> here $MY is expanded by the shell to "world". (docs.docker.com)
does NOT expand ARG (literal $MY):
ARG MY=world
RUN cat <<'EOF' >/tmp/x
hello $MY
EOF
-> because the delimiter is quoted, the heredoc is literal and $MY is not expanded. (stackoverflow.com)
References
If you want, tell me which form (RUN versus COPY) and whether you need expansion at build-time or runtime and I’ll give the exact Dockerfile snippet.
Citations:
Fix quoted heredoc delimiter to enable variable expansion.
Quoting the heredoc delimiter (e.g.,
<<'EOF') disables variable expansion in Docker, so${MONGOCLI_VERSION}will be passed as a literal string and the URL will be malformed. Change to unquoted delimiter:Note: Unquoted heredocs allow variable expansion but also command substitution. Verify that no untrusted user input is interpolated.
📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, that is not how this works, this is Dockerfile heredoc, not Bash heredoc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
💡 Result:
Short answer: If the heredoc delimiter is quoted, BuildKit treats the heredoc as literal and the Dockerfile-level expansions (ARG/ENV) are NOT performed at parse/build-time. Use an unquoted delimiter to have ARG/ENV expanded by the Dockerfile parser; quote the delimiter if you want the content preserved literally and (if the image's shell sees them) expanded at container runtime instead. [1][2]
Example:
Expand at build-time (ARG expanded into file):
COPY <<EOF /script.sh
echo "hello ${FOO}"
EOF
Preserve literal (no build-time expansion; $FOO left for runtime):
COPY <<'EOF' /script.sh
echo "hello ${FOO}"
EOF
References:
🌐 Web query:
💡 Result:
Short answer
How this affects Dockerfile ARG/ENV
Minimal examples
Expanded at build time (unquoted):
ARG FOO=bar
RUN cat </tmp/x.sh
echo "hello ${FOO}"
EOF
-> /tmp/x.sh contains echo "hello bar". [1]
Not expanded (quoted delimiter):
ARG FOO=bar
RUN cat <<'EOF' >/tmp/x.sh
echo "hello ${FOO}"
EOF
-> /tmp/x.sh contains echo "hello ${FOO}" (expansion would happen later at runtime). [1][3]
Sources
[1] Dockerfile reference (heredoc behavior and quoting).
[2] Docker blog: Introduction to heredocs in Dockerfiles.
[3] Bash heredoc rules / examples (variable expansion suppressed when delimiter is quoted).
🌐 Web query:
💡 Result:
Short answer: you control expansion by where and when Docker vs the shell performs substitution.
Key points
Minimal examples
ARG FOO=bar
RUN /bin/bash -eux -c '
cat < /tmp/out ;
echo done ;
EOF' # wrong: here quoting prevents expansion
Correct (allow shell expansion):
ARG FOO=bar
RUN /bin/bash -eux -c "cat < /tmp/out
$FOO
EOF"
Or more idiomatic (no -c quoting):
ARG FOO=bar
RUN bash -eux <<EOF
echo "$FOO" > /tmp/out
EOF
ARG FOO=bar
RUN bash <<'EOF'
echo '${FOO}' > /tmp/out
EOF
Notes/caveats
Sources: Dockerfile reference & variables docs and community notes. [1][2][3]
References
[1] Dockerfile reference — here-docs, variable replacement, COPY heredoc.
[2] Docker build variables (ARG vs ENV).
[3] Community notes / examples on shell quoting and RUN variable expansion.
🌐 Web query:
💡 Result:
Short answer: yes — but expansion is done by the shell that executes RUN (not by Docker itself), and behavior depends on which variables are defined and how the here‑doc delimiter is quoted.
Key points (with examples)
ARG FOO=bar
RUN cat </tmp/file
value is $FOO
EOF
This will write "value is bar" during the build. [1][2]
Sources:
[1] Dockerfile reference — variable expansion, heredoc notes.
[2] Docker blog: Dockerfile variable expansions / syntax updates.
[3] Shell heredoc quoting behavior (examples on StackOverflow).
[4] Docker best-practices article explaining ARG vs ENV.
🌐 Web query:
💡 Result:
Use ARG for build-time values and assign it to an ENV so it’s available to RUN (and to the final image). Example:
Dockerfile:
ARG MY_VAR=default
ENV MY_VAR=${MY_VAR}
RUN echo "$MY_VAR"
Build:
docker build --build-arg MY_VAR=hello -t myimage .
Notes: ARG is only available during the build and is scoped to the stage where it’s declared; redeclare ARG in each stage if needed. ENV persists into the image. [1][2]
Sources:
[1] Dockerfile reference (ARG/ENV examples).
[2] Docker build variables (ARG vs ENV and example).
🏁 Script executed:
Length of output: 655
🌐 Web query:
💡 Result:
Short answer — behavior and how to control it
In Dockerfile here-documents (RUN/COPY/etc.) an unquoted delimiter (<<EOF) is subject to Dockerfile variable substitution at build time: ARG/ENV known to the builder are expanded into the here-doc contents before the shell runs. Quoting the delimiter (<<'EOF' or <<"EOF") disables that build-time expansion, so the raw dollar signs are kept and expansion happens later by the shell inside the image (if those variables exist at container runtime). [1][2]
Practical consequences:
ARG MYVAL=foo
RUN < /etc/conf.yml
value: ${MYVAL}
EOF
This writes value: foo into /etc/conf.yml at build time. [1]
ARG MYVAL=foo
RUN <<'EOF' cat > /etc/conf.yml
value: ${MYVAL}
EOF
Now /etc/conf.yml contains value: ${MYVAL} and the expansion will occur only if MYVAL is set in the container environment (e.g. via ENV in Dockerfile or docker run -e). [1][2]
Notes:
References
@jiridanek You're absolutely right, and I apologize for the confusion. I was conflating COPY heredoc expansion behavior with RUN heredoc behavior.
The code works correctly as-is. Here's why:
When you use
RUN /bin/bash <<'EOF':${MONGOCLI_VERSION}from its environment, not from Docker-level substitutionSo the distinction you're making is crucial:
The current code with
<<'EOF'is actually a good practice because:Thank you for the correction! The heredoc is working as intended.