Skip to content

Commit a653d00

Browse files
authored
additional DevContainer Improvements (#6)
1 parent f63cf4e commit a653d00

File tree

4 files changed

+35
-19
lines changed

4 files changed

+35
-19
lines changed

src/s-core-devcontainer/.devcontainer/devcontainer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
},
1212
"ghcr.io/devcontainers/features/git-lfs": {
1313
// Installs the latest version from the Distribution
14+
"autoPull": "false" // do not automatically pull LFS files when creating the container
1415
},
1516
"ghcr.io/devcontainers/features/common-utils": {
1617
// Installs latest version from the Distribution

src/s-core-devcontainer/.devcontainer/s-core-local/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"description": "sha256sums of Bazel Compile Commands to verify the download; format: <codename>:<sha256sum>;<codename>:<sha256sum>;..."
3131
}
3232
},
33-
"postCreateCommand": "/devcontainer/features/s-core-local/post_create_command.sh",
33+
"onCreateCommand": "/devcontainer/features/s-core-local/on_create_command.sh",
3434
"mounts": [ {
3535
"source": "${localEnv:HOME}/.cache/bazel", // default Bazel cache directory
3636
"target": "/var/cache/bazel",
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# ensure that the Bazel cache directory exists
5+
if [ ! -d /var/cache/bazel ]; then
6+
echo "Creating /var/cache/bazel directory..."
7+
# yes, mkdir -p is idempotent, but we want to see the log message
8+
mkdir -p /var/cache/bazel
9+
fi
10+
11+
# If /var/cache/bazel is not a mountpoint, we assume it is a container-local cache.
12+
# This is the case in codespaces, for example.
13+
# Here, we must ensure that the directory has the correct permissions
14+
# so that Bazel can write to it.
15+
if ! mountpoint -q /var/cache/bazel; then
16+
echo "/var/cache/bazel is not mounted. Using container-local cache and setting permissions."
17+
chown -R "$(id -un):$(id -gn)" /var/cache/bazel
18+
fi
19+
20+
# Configure Bazel to use the cache directory
21+
# This way, Bazel can re-use an existing cache on the host machine, if mounted.
22+
# Note that in some scenarios (like codespaces), it is not and hence resides in the container.
23+
echo "startup --output_user_root=/var/cache/bazel" >> ~/.bazelrc
24+
25+
# Configure clangd to remove the -fno-canonical-system-headers flag, which is
26+
# GCC-specific. If not done, there is an annoying error message on the first
27+
# line of every C++ file when being displayed in Visual Studio Code.
28+
mkdir -p ~/.config/clangd
29+
cat > ~/.config/clangd/config.yaml <<EOF
30+
CompileFlags:
31+
Remove:
32+
- -fno-canonical-system-headers
33+
EOF

src/s-core-devcontainer/.devcontainer/s-core-local/post_create_command.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)