Skip to content

[Other] root Dockerfile: pass the source commit to the terminal stage (source build fails at v0.2.2) - #3644

Closed
robertoetcheverryr wants to merge 2 commits into
Niko1221:mainfrom
robertoetcheverryr:FixContainer
Closed

robertoetcheverryr wants to merge 2 commits into
Niko1221:mainfrom
robertoetcheverryr:FixContainer

Conversation

@robertoetcheverryr

@robertoetcheverryr robertoetcheverryr commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Problem and result

At v0.2.2 (011c9e6) the documented source build (docker build -t strata:src ., "From source" in docs/DOCKER.md) fails in the terminal stage:

the commit of these sources is unknown (no .git here, no --commit, no STRATA_COMMIT): the archive would carry no COMMIT file, and every `strata bench run` on it would be nonconforming

.dockerignore excludes .git, and the root Dockerfile's terminal stage takes no commit argument, so package_terminal.py has nothing to read. After this change the documented commands pass the commit, the build goes through, and the archive carries its COMMIT file.

Related discussion

Same failure reported in a comment on #3503 (closed) and worked around locally in #3624 ("reported separately"). Build and docs fix only, no behavior or default change.

Approach

  • Dockerfile: the same handling docker/Dockerfile already uses, ARG STRATA_COMMIT → ENV STRATA_BUILD_COMMIT, which build_commit() already reads. Two lines in the terminal stage.
  • docs/DOCKER.md: both "From source" commands (CUDA 13 and cuda12) now pass --build-arg STRATA_COMMIT=$(git rev-parse HEAD), with one sentence on why.

Without the arg the value is empty, build_commit() rejects it and the build stops with the same message as before.

Validation

Passed:

  • sudo docker compose build --build-arg STRATA_COMMIT=$(sudo git -C app rev-parse HEAD) (compose build context = repo clone, args CUDA_ARCHITECTURES: "86"), v0.2.2 011c9e6 plus this change, Debian 13, Docker 29.9.2 (a82e528), RTX 3090: image built in 1056.1 s, terminal stage strata --version passed. COMMIT file carried into the image:

    $ docker run --rm --entrypoint cat strata:local /opt/strata/terminal/COMMIT
    011c9e600a93bbc9fd451c563501b5831c32bbca
    

Failed:

  • Same build without this change: fails at [terminal 4/5] with the message above.

Not run:

  • cuda12 variant, HIP, SYCL: not built. The change is in the terminal stage only, which doesn't depend on the backend.
  • docker/Dockerfile / docker/build.sh: not touched.
  • The docs commands exactly as written (docker build -t strata:src ...): built through docker compose with the same build arg instead.

Limits

A bare docker build . without the arg still stops, as the packager intends (it refuses an archive with no commit). Making it work with no arg would mean either keeping .git in the build context or letting the packager warn instead of fail. I left both out because they change existing behavior; happy to do either if preferred.

@robertoetcheverryr
robertoetcheverryr marked this pull request as ready for review October 21, 2026 20:34
@OcBuddy

OcBuddy commented Oct 22, 2026

Copy link
Copy Markdown

Did you run on a clean pull from the repo?
Because here - i made the changes from your commit- i got:
I did a git reset --hard befor ei made the changes. So these two lines and the added '--build-arg STRATA_COMMIT=$(git rev-parse HEAD) ' are the only things changed.

My build script for reference.

#!/bin/sh
# Build the Strata Docker image from the Dockerfile at the repo root and tag it `strata`.
set -eu

here=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)

docker build --build-arg CUDA_ARCHITECTURES=75 --build-arg STRATA_COMMIT=$(git rev-parse HEAD) -t strata "$here"
 => ERROR [terminal 4/5] RUN python3 /src/packaging/package_terminal.py --out /out --cache /cache  && mkdir -p /opt/strata  && tar -xzf /out/strata-  35.0s
 => CANCELED [engine-build 2/8] RUN apt-get update && apt-get install -y --no-install-recommends         build-essential ca-certificates git libgomp1  0.0s
------
 > [terminal 4/5] RUN python3 /src/packaging/package_terminal.py --out /out --cache /cache  && mkdir -p /opt/strata  && tar -xzf /out/strata-terminal-*-linux-x86_64.tar.gz -C /opt/strata  && mv /opt/strata/strata-terminal-* /opt/strata/terminal  && /opt/strata/terminal/bin/strata --version:
34.88 fetching the pinned CPython from https://github.com/astral-sh/python-build-standalone/releases/download/20261009/cpython-3.12.15%2B20261009-x86_64-unknown-linux-gnu-install_only.tar.gz
34.88 unpacking the interpreter
34.88 copying the application
34.88 Traceback (most recent call last):
34.88   File "/src/packaging/package_terminal.py", line 530, in <module>
34.88     sys.exit(main())
34.88              ^^^^^^
34.88   File "/src/packaging/package_terminal.py", line 374, in main
34.88     installer = None if args.no_installer else add_installer(root)
34.88                                                ^^^^^^^^^^^^^^^^^^^
34.88   File "/src/packaging/package_terminal.py", line 264, in add_installer
34.88     shutil.copytree(source / INSTALLER_DATA, folder / INSTALLER_DATA, ignore=shutil.ignore_patterns("__pycache__"))
34.88   File "/usr/lib/python3.12/shutil.py", line 600, in copytree
34.88     return _copytree(entries=entries, src=src, dst=dst, symlinks=symlinks,
34.88            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
34.88   File "/usr/lib/python3.12/shutil.py", line 554, in _copytree
34.88     raise Error(errors)
34.88 shutil.Error: [('/src/data/install/third_party/llama.cpp', '/tmp/strata-terminal-build-_cukw2d9/strata-terminal-0.1.47-linux-x86_64/data/install/third_party/llama.cpp', "[Errno 2] No such file or directory: '/src/data/install/third_party/llama.cpp'")]
------
Dockerfile:75
--------------------
  74 |     COPY . /src/
  75 | >>> RUN python3 /src/packaging/package_terminal.py --out /out --cache /cache \
  76 | >>>  && mkdir -p /opt/strata \
  77 | >>>  && tar -xzf /out/strata-terminal-*-linux-x86_64.tar.gz -C /opt/strata \
  78 | >>>  && mv /opt/strata/strata-terminal-* /opt/strata/terminal \
  79 | >>>  && /opt/strata/terminal/bin/strata --version
  80 |     # llama.cpp at the commit setup.py pins: fetched here, so the first start does not depend on GitHub. Only gguf-py (the model preparation
--------------------
ERROR: failed to build: failed to solve: process "/bin/sh -c python3 /src/packaging/package_terminal.py --out /out --cache /cache  && mkdir -p /opt/strata  && tar -xzf /out/strata-terminal-*-linux-x86_64.tar.gz -C /opt/strata  && mv /opt/strata/strata-terminal-* /opt/strata/terminal  && /opt/strata/terminal/bin/strata --version" did not complete successfully: exit code: 1


@robertoetcheverryr

robertoetcheverryr commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Did you run on a clean pull from the repo? Because here - i made the changes from your commit- i got: I did a git reset --hard befor ei made the changes. So these two lines and the added '--build-arg STRATA_COMMIT=$(git rev-parse HEAD) ' are the only things changed.

My build script for reference.

#!/bin/sh
# Build the Strata Docker image from the Dockerfile at the repo root and tag it `strata`.
set -eu

here=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)

docker build --build-arg CUDA_ARCHITECTURES=75 --build-arg STRATA_COMMIT=$(git rev-parse HEAD) -t strata "$here"
 => ERROR [terminal 4/5] RUN python3 /src/packaging/package_terminal.py --out /out --cache /cache  && mkdir -p /opt/strata  && tar -xzf /out/strata-  35.0s
 => CANCELED [engine-build 2/8] RUN apt-get update && apt-get install -y --no-install-recommends         build-essential ca-certificates git libgomp1  0.0s
------
 > [terminal 4/5] RUN python3 /src/packaging/package_terminal.py --out /out --cache /cache  && mkdir -p /opt/strata  && tar -xzf /out/strata-terminal-*-linux-x86_64.tar.gz -C /opt/strata  && mv /opt/strata/strata-terminal-* /opt/strata/terminal  && /opt/strata/terminal/bin/strata --version:
34.88 fetching the pinned CPython from https://github.com/astral-sh/python-build-standalone/releases/download/20261009/cpython-3.12.15%2B20261009-x86_64-unknown-linux-gnu-install_only.tar.gz
34.88 unpacking the interpreter
34.88 copying the application
34.88 Traceback (most recent call last):
34.88   File "/src/packaging/package_terminal.py", line 530, in <module>
34.88     sys.exit(main())
34.88              ^^^^^^
34.88   File "/src/packaging/package_terminal.py", line 374, in main
34.88     installer = None if args.no_installer else add_installer(root)
34.88                                                ^^^^^^^^^^^^^^^^^^^
34.88   File "/src/packaging/package_terminal.py", line 264, in add_installer
34.88     shutil.copytree(source / INSTALLER_DATA, folder / INSTALLER_DATA, ignore=shutil.ignore_patterns("__pycache__"))
34.88   File "/usr/lib/python3.12/shutil.py", line 600, in copytree
34.88     return _copytree(entries=entries, src=src, dst=dst, symlinks=symlinks,
34.88            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
34.88   File "/usr/lib/python3.12/shutil.py", line 554, in _copytree
34.88     raise Error(errors)
34.88 shutil.Error: [('/src/data/install/third_party/llama.cpp', '/tmp/strata-terminal-build-_cukw2d9/strata-terminal-0.1.47-linux-x86_64/data/install/third_party/llama.cpp', "[Errno 2] No such file or directory: '/src/data/install/third_party/llama.cpp'")]
------
Dockerfile:75
--------------------
  74 |     COPY . /src/
  75 | >>> RUN python3 /src/packaging/package_terminal.py --out /out --cache /cache \
  76 | >>>  && mkdir -p /opt/strata \
  77 | >>>  && tar -xzf /out/strata-terminal-*-linux-x86_64.tar.gz -C /opt/strata \
  78 | >>>  && mv /opt/strata/strata-terminal-* /opt/strata/terminal \
  79 | >>>  && /opt/strata/terminal/bin/strata --version
  80 |     # llama.cpp at the commit setup.py pins: fetched here, so the first start does not depend on GitHub. Only gguf-py (the model preparation
--------------------
ERROR: failed to build: failed to solve: process "/bin/sh -c python3 /src/packaging/package_terminal.py --out /out --cache /cache  && mkdir -p /opt/strata  && tar -xzf /out/strata-terminal-*-linux-x86_64.tar.gz -C /opt/strata  && mv /opt/strata/strata-terminal-* /opt/strata/terminal  && /opt/strata/terminal/bin/strata --version" did not complete successfully: exit code: 1

Since I built it with a docker compose instead of manually, something might have been different, I will check in a completely clean environment.

@akivajp

akivajp commented Oct 22, 2026

Copy link
Copy Markdown

I checked both points on a clean worktree of this PR's head (fb957cb). Environment: Ubuntu 26.04, plain docker build (no compose).

1. The documented command works. This covers the "docs commands as written" item, for the terminal stage only:

docker build --target terminal --build-arg STRATA_COMMIT=$(git rev-parse HEAD) .

It passed, and /opt/strata/terminal/COMMIT in the image is fb957cb2…. Earlier I built the full image with the same ARG/ENV handling applied locally on 011c9e6 (CUDA_ARCHITECTURES=89, for #3624), and that build passed too.

2. @OcBuddy's error is reproduced exactly by a dangling symlink in the checkout:

mkdir -p data/install/third_party
ln -s /opt/strata/seed/third_party/llama.cpp data/install/third_party/llama.cpp
docker build --target terminal --build-arg STRATA_COMMIT=$(git rev-parse HEAD) .
# shutil.Error: [('/src/data/install/third_party/llama.cpp', '/tmp/strata-terminal-build-.../data/install/third_party/llama.cpp', "[Errno 2] No such file or directory: '/src/data/install/third_party/llama.cpp'")]

docker/entrypoint.sh (lines 46–49) creates exactly this link inside /data. My guess is that the clone's data/ folder was mounted as the container's /data at some point. That is unconfirmed: I have only reproduced the symptom, not that setup. git reset --hard keeps untracked files, which would explain why a reset did not help.

  • To check: git status --short shows ?? data/install/.
  • To fix the checkout: git clean -fdx data/.
  • To make the build robust: add the runtime folders that entrypoint.sh creates (data/install/, data/state/, data/home/, data/Strata-data/) to .dockerignore. That would also keep any downloaded models out of the build context.

@robertoetcheverryr

robertoetcheverryr commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Second confirmation here.

cd /tmp && rm -rf strata-clean && git clone https://github.com/robertoetcheverryr/Strata strata-clean && cd strata-clean && git checkout FixContainer
docker build --no-cache --progress=plain --build-arg CUDA_ARCHITECTURES=86 --build-arg STRATA_COMMIT=$(git rev-parse HEAD) -t strata-test . 2>&1 | tee /tmp/strata-build.log

Built the image correctly and no errors in the log

NOTE: git reset does not remove untracked/ignored files and the directory that failed is not part of the tree (it is downloaded later) so it explains why it failed for OcBuddy

@OcBuddy

OcBuddy commented Oct 23, 2026

Copy link
Copy Markdown

Second confirmation here.

cd /tmp && rm -rf strata-clean && git clone https://github.com/robertoetcheverryr/Strata strata-clean && cd strata-clean && git checkout FixContainer
docker build --no-cache --progress=plain --build-arg CUDA_ARCHITECTURES=86 --build-arg STRATA_COMMIT=$(git rev-parse HEAD) -t strata-test . 2>&1 | tee /tmp/strata-build.log

Built the image correctly and no errors in the log

NOTE: git reset does not remove untracked/ignored files and the directory that failed is not part of the tree (it is downloaded later) so it explains why it failed for OcBuddy

Running these commands from your repo it build.

@const-apex

Copy link
Copy Markdown

Confirming this fix on Linux with v0.2.3.1 (commit 7ddc17a).

Without it, docker build of the root Dockerfile stops in the terminal stage: package_terminal.py says the commit of the sources is unknown, because .dockerignore drops .git. With the two lines from this PR (ARG STRATA_COMMIT / ENV STRATA_BUILD_COMMIT=${STRATA_COMMIT} in the terminal stage), plus --build-arg STRATA_COMMIT=$(git rev-parse HEAD), the build completes. /opt/strata/terminal/COMMIT then holds 7ddc17a.

Build: CUDA_ARCHITECTURES=86, BUILD_VISION=1, CUDA 13.0 base images, Docker 29.8.1, about 35 minutes for the first build, cached rebuild about 500 s.

The image runs on one or both cards with pictured on, using Qwen3.8-Flash-Next from 1-bit up to Q8_0 and on RTX A5000 (driver 595.104.02).

Niko1221 pushed a commit that referenced this pull request Oct 27, 2026
…stage (#3644)

.git is not in the build context, so package_terminal.py had no commit to put in the archive and the documented source build stopped.
Ported from PR #3644 by robertoetcheverryr: ARG STRATA_COMMIT / ENV STRATA_BUILD_COMMIT as in docker/Dockerfile, and the two 'From source'
commands in docs/DOCKER.md pass --build-arg STRATA_COMMIT=$(git rev-parse HEAD).

Added: .dockerignore leaves out the folders docker/entrypoint.sh creates in a mounted data/ (install, state, home, Strata-data). A dangling
data/install/third_party/llama.cpp link in a clone that had been mounted made the Terminal stage fail with a copytree error (seen in the
review thread of #3644). Not built with docker here (no docker on this PC).
Niko1221 added a commit that referenced this pull request Oct 27, 2026
@Niko1221

Copy link
Copy Markdown
Owner

Thanks. Confirmed: the root Dockerfile passes no commit to the Terminal stage, so package_terminal stops. Ported with your docs change, plus a .dockerignore line for the folders the entrypoint creates in data/ (the failure OcBuddy hit). Fixed in 0.2.7.

Release: https://github.com/Niko1221/Strata/releases/tag/v0.2.7

@Niko1221 Niko1221 closed this Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants