Skip to content

Conversation

@opajonk
Copy link
Contributor

@opajonk opajonk commented Aug 20, 2025

Since bind-mounting the Bazel cache from the host causes various problems (problematic access rights; incompatibilities with CodeSpaces) without major benefits, we use now a regular named volume as persistent cache.

Closes #18 (now hopefully for real)

Since bind-mounting the Bazel cache from the host causes various problems (problematic access rights; incompatibilities with CodeSpaces) without major benefits, we use now a regular named volume as persistent cache.
@opajonk opajonk marked this pull request as ready for review August 20, 2025 08:41
@AlexanderLanin
Copy link
Member

AlexanderLanin commented Aug 20, 2025

I cannot open a codespace on https://github.com/Elektrobit/eclipse-score_devcontainer/tree/use-docker-volume-as-bazel-cache:

Running the postCreateCommand from Feature 'ghcr.io/devcontainers/features/git-lfs:1'...

/usr/local/share/pull-git-lfs-artifacts.sh
Fetching git lfs artifacts...
Hook already exists: post-commit

        #!/bin/bash

        # This is a custom git hook installed for codespaces when you'll be unable to push your changes to the source repository.
        # Instead, we'll fork the repo on your behalf, ensure you have appropriate permissions, and transfer the codespace to that fork.

        trap "mv $0 $0.codespaces-disabled" EXIT

        echo "You don't have write access to the $GITHUB_REPOSITORY repository, so you cannot push changes to it."
        echo "To obtain write access we will point this codespace at your fork of $GITHUB_REPOSITORY, creating that fork if it doesn't exist."
        echo

        if [ -t 1 ]; then
        read -p "Would you like to proceed? " -n 1 -r < /dev/tty
        echo
        if [[ ! $REPLY =~ ^[Yy]$ ]]
        then
        exit 0
        fi
        fi

        URL="********/vscs_internal/user/$GITHUB_USER/codespaces/$CODESPACE_NAME/fork_repo"


        current_branch=$(git rev-parse --abbrev-ref HEAD)

        response=$(curl -s -w "%{http_code}" -X POST -H "Authorization: token $GITHUB_TOKEN" -d "{\"branch\":\"$current_branch\"}" $URL)

        # Grab the last line which is the status code
        http_cod

To resolve this, either:
  1: run `git lfs update --manual` for instructions on how to merge hooks.
  2: run `git lfs update --force` to overwrite your hook.
[1411 ms] postCreateCommand from Feature 'ghcr.io/devcontainers/features/git-lfs:1' failed with exit code 2. Skipping any further user-provided commands.

Error: Command failed: /bin/sh -c /usr/local/share/pull-git-lfs-artifacts.sh
    at E (/.codespaces/agent/bin/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:235:157)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.allSettled (index 0)
    at async b9 (/.codespaces/agent/bin/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:237:119)
    at async ND (/.codespaces/agent/bin/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:226:4668)
    at async RD (/.codespaces/agent/bin/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:226:4013)
    at async MD (/.codespaces/agent/bin/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:226:3217)
    at async Zg (/.codespaces/agent/bin/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:226:2623)
    at async m6 (/.codespaces/agent/bin/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:467:1526)
    at async ax (/.codespaces/agent/bin/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:467:960)
{"outcome":"error","message":"Command failed: /bin/sh -c /usr/local/share/pull-git-lfs-artifacts.sh","description":"postCreateCommand from Feature 'ghcr.io/devcontainers/features/git-lfs:1' failed.","containerId":"ec8922ce7c6a30bcfda6c1b5644eb05b6e29b16c1c4931a001d04700c4d55aed"}

Correction: it seems to open regardless of that error.

Nothing bazel or cache related in the log.

@AlexanderLanin
Copy link
Member

Oh Skipping any further user-provided commands. that may be a problem 😆

it can cause some weird issues with CodeSpaces, and we do not use it directly at the moment anyway
@opajonk
Copy link
Contributor Author

opajonk commented Aug 20, 2025

Well, and the fact that this repository does not use the DevContainer it creates (chicken-egg-problem ;-). It also does not use Bazel (no use for it, since the build must be done using devcontainer-cli anyway).

Anyway, I tried to run a CodeSpace on it, and that just worked fine. Apparently the failure has something to do with access rights (you have no write access to this fork), some CodeSpaces magic that will do a fork on your behalf, and an implementation detail of this forking (it uses a post-commit hook) conflicting with the git lfs feature. Oh boy ;-)

Anyway, I disabled the auto-fetch of git lfs also here for now, since we do not use it directly at the moment.

AlexanderLanin
AlexanderLanin previously approved these changes Aug 20, 2025
it is not required anymore, since now a volume mount is used instead of a bind mount
@lurtz
Copy link
Contributor

lurtz commented Aug 20, 2025

Well, and the fact that this repository does not use the DevContainer it creates (chicken-egg-problem ;-). It also does not use Bazel (no use for it, since the build must be done using devcontainer-cli anyway).

We could try building the container using bazel

@AlexanderLanin
Copy link
Member

Are you now mounting the local eclipse-s-core-bazel-cache located in the respective repo? Or am I reading the mount incorrectly?

@lurtz
Copy link
Contributor

lurtz commented Aug 20, 2025

Are you now mounting the local eclipse-s-core-bazel-cache located in the respective repo? Or am I reading the mount incorrectly?

It should be a Docker volume. Thus it is still somewhere on the host, but under full control of Docker. If it does not exist, Docker will take care to create it.

Among the many repos / devcontainer instances it will still be shared.

@AlexanderLanin
Copy link
Member

Ah I see. But it will not be shared with non-devcontainer bazel-cache. I guess that's fine. Until people run out of disk space 😆

@AlexanderLanin AlexanderLanin merged commit f73e1e0 into eclipse-score:main Aug 20, 2025
2 checks passed
@opajonk opajonk deleted the use-docker-volume-as-bazel-cache branch August 20, 2025 11:13
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.

codespace support

3 participants