Skip to content

Commit 3d80c01

Browse files
authored
Release/v2.4.2 (#27)
* feat: Mount only /root/.local/(share|state) CC places binary in /root/.local/bin. However, OpenCode stores configs in /root/.local/share & state, so we still have to mount. * v2.4.2 * feat: postinstall.js: Add old mounts cleanup
1 parent eae8c79 commit 3d80c01

6 files changed

Lines changed: 46 additions & 5 deletions

File tree

docs/ConsumerGuide.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ All container data is stored in `~/.code-container/`:
5959
│ ├── .codex/
6060
│ ├── .gemini/
6161
│ ├── .local/
62+
│ │ ├── share/
63+
│ │ └── state/
6264
│ └── .opencode/
6365
├── Dockerfile.User # User customizations layered on base image
6466
├── MOUNTS.txt # Additional mount points

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "code-container",
3-
"version": "2.4.1",
3+
"version": "2.4.2",
44
"description": "Manage isolated Docker containers for running coding tools on different projects",
55
"main": "dist/main.js",
66
"bin": {

scripts/postinstall.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,40 @@ if (!fs.existsSync(FLAGS_PATH)) {
3030
if (!fs.existsSync(RUN_FLAGS_PATH)) {
3131
fs.writeFileSync(RUN_FLAGS_PATH, "# Add Docker run-only flags here (one per line)\n# Note: These flags are only passed to 'docker run', not 'docker exec'.\n# Use this for flags like -v, --network, --restart that are not valid for exec.\n");
3232
}
33+
34+
// --- Migration: Remove stale core mounts from MOUNTS.txt ---
35+
// Prior to v2.2.0, `container init` wrote core mounts directly into MOUNTS.txt.
36+
// Core mounts are now applied in-memory at runtime (see getCoreMounts() in mounts.ts).
37+
// Old entries in MOUNTS.txt can conflict with updated core mounts (e.g. the old
38+
// /root/.local mount shadows the new /root/.local/share and /root/.local/state mounts).
39+
// This block removes those stale entries on upgrade.
40+
const MOUNTS_PATH = path.join(APPDATA_DIR, "MOUNTS.txt");
41+
const STALE_CONTAINER_PATHS = [
42+
"/root/.claude",
43+
"/root/.claude.json",
44+
"/root/.codex",
45+
"/root/.copilot",
46+
"/root/.config/opencode",
47+
"/root/.gemini",
48+
"/root/.local",
49+
"/root/.gitconfig",
50+
];
51+
52+
if (fs.existsSync(MOUNTS_PATH)) {
53+
const content = fs.readFileSync(MOUNTS_PATH, "utf-8");
54+
const lines = content.split("\n");
55+
const cleaned = lines.filter(line => {
56+
// Filter out all lines with target location in STALE_CONTAINER_PATHS
57+
const trimmed = line.trim();
58+
if (!trimmed || trimmed.startsWith("#")) return true;
59+
const parts = trimmed.split(":");
60+
const containerPath = parts.length >= 2 ? parts[1] : null;
61+
return containerPath === null || !STALE_CONTAINER_PATHS.includes(containerPath);
62+
});
63+
const cleanedContent = cleaned.join("\n");
64+
if (cleanedContent !== content) {
65+
fs.writeFileSync(MOUNTS_PATH, cleanedContent, { mode: 0o600 });
66+
console.log("Note: Removed outdated core mounts from MOUNTS.txt")
67+
}
68+
}
69+
// --- End Migration ---

src/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export const SHARED_DIRS = [
1515
".claude",
1616
".codex",
1717
".copilot",
18-
".local",
18+
".local/share",
19+
".local/state",
1920
".opencode",
2021
".gemini",
2122
];

src/mounts.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ function getCoreMounts(): string[] {
1212
`${CONFIGS_DIR}/.copilot:/root/.copilot`,
1313
`${CONFIGS_DIR}/.opencode:/root/.config/opencode`,
1414
`${CONFIGS_DIR}/.gemini:/root/.gemini`,
15-
`${CONFIGS_DIR}/.local:/root/.local`,
15+
`${CONFIGS_DIR}/.local/share:/root/.local/share`,
16+
`${CONFIGS_DIR}/.local/state:/root/.local/state`,
1617
`${home}/.gitconfig:/root/.gitconfig:ro`,
1718
];
1819
}

0 commit comments

Comments
 (0)