Skip to content

Commit 4a96ef1

Browse files
authored
chore(devtools): devcontainer allows go and rust repos (onyx-dot-app#10041)
1 parent 822b0c9 commit 4a96ef1

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"source=${localEnv:HOME}/.gitconfig,target=/home/dev/.gitconfig.host,type=bind,readonly",
1111
"source=${localEnv:HOME}/.ssh,target=/home/dev/.ssh.host,type=bind,readonly",
1212
"source=${localEnv:HOME}/.config/nvim,target=/home/dev/.config/nvim.host,type=bind,readonly",
13+
"source=onyx-devcontainer-cache,target=/home/dev/.cache,type=volume",
1314
"source=onyx-devcontainer-local,target=/home/dev/.local,type=volume"
1415
],
1516
"remoteUser": "dev",

.devcontainer/init-dev-user.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -euo pipefail
55
# bind-mounted files are accessible without running as root.
66
#
77
# Standard Docker: Workspace is owned by the host user's UID (e.g. 1000).
8-
# We remap dev to that UID fast and seamless.
8+
# We remap dev to that UID -- fast and seamless.
99
#
1010
# Rootless Docker: Workspace appears as root-owned (UID 0) inside the
1111
# container due to user-namespace mapping. We can't remap
@@ -23,9 +23,10 @@ DEV_GID=$(id -g "$TARGET_USER")
2323
DEV_HOME=/home/"$TARGET_USER"
2424

2525
# Ensure directories that tools expect exist under ~dev.
26-
# ~/.local is a named Docker volume — ensure subdirs exist and are owned by dev.
26+
# ~/.local and ~/.cache are named Docker volumes -- ensure they are owned by dev.
2727
mkdir -p "$DEV_HOME"/.local/state "$DEV_HOME"/.local/share
2828
chown -R "$TARGET_USER":"$TARGET_USER" "$DEV_HOME"/.local
29+
chown -R "$TARGET_USER":"$TARGET_USER" "$DEV_HOME"/.cache
2930

3031
# Copy host configs mounted as *.host into their real locations.
3132
# This gives the dev user owned copies without touching host originals.
@@ -41,7 +42,7 @@ if [ -d "$DEV_HOME/.config/nvim.host" ]; then
4142
chown -R "$TARGET_USER":"$TARGET_USER" "$DEV_HOME/.config/nvim"
4243
fi
4344

44-
# Already matching nothing to do.
45+
# Already matching -- nothing to do.
4546
if [ "$WS_UID" = "$DEV_UID" ] && [ "$WS_GID" = "$DEV_GID" ]; then
4647
exit 0
4748
fi

.devcontainer/init-firewall.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fi
2424
ipset create allowed-domains hash:net || true
2525
ipset flush allowed-domains
2626

27-
# Fetch GitHub IP ranges (IPv4 only ipset hash:net and iptables are IPv4)
27+
# Fetch GitHub IP ranges (IPv4 only -- ipset hash:net and iptables are IPv4)
2828
GITHUB_IPS=$(curl -s https://api.github.com/meta | jq -r '.api[]' 2>/dev/null | grep -v ':' || echo "")
2929
for ip in $GITHUB_IPS; do
3030
if ! ipset add allowed-domains "$ip" -exist 2>&1; then
@@ -42,6 +42,9 @@ ALLOWED_DOMAINS=(
4242
"update.code.visualstudio.com"
4343
"pypi.org"
4444
"files.pythonhosted.org"
45+
"go.dev"
46+
"storage.googleapis.com"
47+
"static.rust-lang.org"
4548
)
4649

4750
for domain in "${ALLOWED_DOMAINS[@]}"; do

0 commit comments

Comments
 (0)