Skip to content

Commit 6c42aee

Browse files
committed
Update sandcat
1 parent e479073 commit 6c42aee

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

.devcontainer/Dockerfile.app

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,25 @@ RUN mise use -g node@lts \
2222
RUN mise use -g java@21
2323
RUN mise use -g sbt@1.12
2424

25+
# If Java was installed above, bake JAVA_HOME and trust-store paths into the
26+
# image. VS Code may probe the environment before the entrypoint finishes
27+
# importing the mitmproxy CA; having these ready avoids a race where Metals
28+
# (or other JVM tooling) starts without JAVA_HOME or JAVA_TOOL_OPTIONS.
29+
# The entrypoint will import the mitmproxy CA into the cacerts copy at runtime.
30+
RUN if MISE_JAVA=$(mise where java 2>/dev/null); then \
31+
dir="$HOME/.local/share/sandcat"; mkdir -p "$dir"; \
32+
ln -sfn "$MISE_JAVA" "$dir/java-home"; \
33+
cp "$MISE_JAVA/lib/security/cacerts" "$dir/cacerts" 2>/dev/null || true; \
34+
{ echo ''; \
35+
echo '# sandcat-java-env'; \
36+
echo '_sc_java="$HOME/.local/share/sandcat/java-home"'; \
37+
echo '_sc_cacerts="$HOME/.local/share/sandcat/cacerts"'; \
38+
echo '[ -L "$_sc_java" ] && export JAVA_HOME="$_sc_java"'; \
39+
echo '[ -f "$_sc_cacerts" ] && export JAVA_TOOL_OPTIONS="-Djavax.net.ssl.trustStore=$_sc_cacerts -Djavax.net.ssl.trustStorePassword=changeit"'; \
40+
echo 'unset _sc_java _sc_cacerts'; \
41+
} >> "$HOME/.bashrc"; \
42+
fi
43+
2544
# Pre-create the Claude config directory and seed onboarding flag so Claude
2645
# Code can use an API key from the environment without interactive setup.
2746
RUN mkdir -p /home/vscode/.claude \

.devcontainer/sandcat/scripts/app-init.sh

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,6 @@ fi
5858
# Run vscode-user tasks: git identity and Claude Code update.
5959
su - vscode -c /usr/local/bin/app-user-init.sh
6060

61-
# If app-user-init.sh set up Java (symlink + trust store), export JAVA_HOME
62-
# and JAVA_TOOL_OPTIONS for shells and child processes of PID 1.
63-
SANDCAT_JAVA_HOME="/home/vscode/.local/share/sandcat/java-home"
64-
if [ -L "$SANDCAT_JAVA_HOME" ]; then
65-
export JAVA_HOME="$SANDCAT_JAVA_HOME"
66-
echo "export JAVA_HOME=\"$SANDCAT_JAVA_HOME\"" > /etc/profile.d/sandcat-java.sh
67-
fi
68-
if [ -f /tmp/sandcat-java-cacerts-path ]; then
69-
SANDCAT_CACERTS=$(cat /tmp/sandcat-java-cacerts-path)
70-
JAVA_TRUST_OPTS="-Djavax.net.ssl.trustStore=$SANDCAT_CACERTS -Djavax.net.ssl.trustStorePassword=changeit"
71-
export JAVA_TOOL_OPTIONS="$JAVA_TRUST_OPTS"
72-
echo "export JAVA_TOOL_OPTIONS=\"$JAVA_TRUST_OPTS\"" >> /etc/profile.d/sandcat-java.sh
73-
rm -f /tmp/sandcat-java-cacerts-path
74-
fi
75-
7661
# Source all sandcat profile.d scripts from /etc/bash.bashrc so env vars
7762
# are available in non-login shells (e.g. VS Code integrated terminals).
7863
# Guard with a marker to avoid duplicating on container restart.

.devcontainer/sandcat/scripts/app-user-init.sh

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,10 @@ if [ -n "$MISE_JAVA_HOME" ] && [ -f "$CA_CERT" ]; then
7171
EOFJSON
7272
fi
7373

74-
# Signal to app-init.sh (which runs as root) where the cacerts copy is,
75-
# so it can set JAVA_TOOL_OPTIONS. Written on every start since /tmp
76-
# is cleared on container restart.
77-
if [ -f "$SANDCAT_CACERTS" ]; then
78-
echo "$SANDCAT_CACERTS" > /tmp/sandcat-java-cacerts-path
79-
fi
80-
8174
# Write Java env vars to ~/.bashrc (on the persistent app-home volume)
8275
# so VS Code's userEnvProbe picks them up even after container rebuild.
83-
# /etc/profile.d/ is ephemeral and works for shells, but VS Code may
84-
# probe the environment before the entrypoint recreates those files.
76+
# The Dockerfile bakes these into the image for first-run, but rebuilds
77+
# with a changed toolchain need the runtime fallback.
8578
BASHRC_JAVA_MARKER="# sandcat-java-env"
8679
if ! grep -q "$BASHRC_JAVA_MARKER" "$HOME/.bashrc" 2>/dev/null; then
8780
cat >> "$HOME/.bashrc" << 'BASHRC_JAVA'

0 commit comments

Comments
 (0)