Skip to content

Commit 7567717

Browse files
authored
Release/v2.4.0 (#23)
- SEMI-BREAKING: Add new `~/.code-container/Dockerfile.User` for increased extensibility; add commands to `Dockerfile.User` to run custom commands instead of to a copy of `Dockerfile`. - Reorganized documentation --- * docs: Update documentation * feat: Use Dockerfile.User Replace ~/.code-container/Dockerfile with ~/.code-container/Dockerfile.User for improved extensibility * docs: AGENTS.md: Remove old reference * v2.4.0
1 parent c66c0d3 commit 7567717

12 files changed

Lines changed: 51 additions & 100 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
22
dist
3+
internal

.ignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!internal

AGENTS.md

Lines changed: 2 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ If your user asks questions like:
1010

1111
Then your user is a **consumer**.
1212
- The user is seeking your assistance in helping them setup or configure this project.
13-
- Next step: **Read `internal/ConsumerGuide.md`** and assist the user in installing or configurating `container`.
13+
- Next step: **Read `docs/ConsumerGuide.md`** and assist the user in installing or configurating `container`.
1414

1515
If your user is a developer, proceed like normal.
1616

@@ -30,84 +30,11 @@ If your user is a developer, proceed like normal.
3030
## Key Features
3131

3232
- **Security**: Destructive operations localized to containers
33-
- **Customization**: Add packages via `~/.code-container/Dockerfile`, mounts via `MOUNTS.txt`, flags via `DOCKER_FLAGS.txt` and `DOCKER_RUN_FLAGS.txt`
33+
- **Customization**: Add packages via `~/.code-container/Dockerfile.User`, mounts via `MOUNTS.txt`, flags via `DOCKER_FLAGS.txt` and `DOCKER_RUN_FLAGS.txt`
3434
- **Simultaneous Work**: Multiple agents can work on same project safely
3535
- **Persistence**: Container state and harness configs persist
3636

3737
## Requirements
3838

3939
- Docker (Desktop or Engine)
4040
- POSIX system (Linux, macOS, WSL)
41-
42-
---
43-
44-
# Project Index
45-
46-
**Important Rule: Always update this index after creating new code files or making significant changes to existing files.**
47-
48-
## Directory Structure
49-
50-
```
51-
/root/code-container/
52-
├── src/ # TypeScript source code (main codebase)
53-
├── scripts/ # Utility scripts (install, migrate, cleanup)
54-
├── internal/ # Internal documentation
55-
├── dist/ # Compiled JavaScript output (generated)
56-
├── .github/workflows/ # CI/CD workflows
57-
├── Dockerfile # Container image definition
58-
├── package.json # NPM package manifest
59-
└── tsconfig.json # TypeScript configuration
60-
```
61-
62-
## Source Files Index (`src/`)
63-
64-
### Entry Point
65-
66-
- `src/main.ts` — CLI entry point. Parses arguments, displays TOS, routes to commands. Supports: `run`, `build`, `init`, `stop`, `remove`, `list`, `clean`.
67-
68-
### Core Modules
69-
70-
- `src/commands.ts` — Business logic for all CLI commands. Image building, container lifecycle, listing, cleaning. Exports: `buildImage`, `init`, `runContainer`, `stopContainerForProject`, `removeContainerForProject`, `listContainers`, `cleanContainers`
71-
- `src/docker.ts` — Low-level Docker CLI wrappers. Image/container operations, interactive sessions, naming via SHA1 hash. Exports: `checkDocker`, `imageExists`, `buildImageRaw`, `containerExists`, `containerRunning`, `createNewContainer`, `execInteractive`, `stopContainer`, `startContainer`, `removeContainer`, `generateContainerName`
72-
- `src/config.ts` — Configuration paths and settings persistence. Manages `~/.code-container/` directory. Exports: `APPDATA_DIR`, `CONFIGS_DIR`, `DOCKERFILE_PATH`, `SETTINGS_PATH`, `MOUNTS_PATH`, `FLAGS_PATH`, `RUN_FLAGS_PATH`, `loadSettings`, `saveSettings`, `copyConfigs`, `ensureConfigDir`
73-
- `src/mounts.ts` — Volume mount management. Core mounts (configs, gitconfig) and optional SSH mounting. Exports: `ensureMountsFile`, `loadMounts`, `getCoreMounts`
74-
- `src/flags.ts` — Custom Docker flags loaders from `DOCKER_FLAGS.txt` and `DOCKER_RUN_FLAGS.txt`. Uses shell-quote for safe parsing. `DOCKER_FLAGS.txt` is loaded for both `docker run` and `docker exec`. `DOCKER_RUN_FLAGS.txt` is loaded only for `docker run`. Exports: `loadFlags`, `loadRunFlags`
75-
- `src/utils.ts` — Colored console output and user prompts. Exports: `printInfo`, `printSuccess`, `printWarning`, `printError`, `promptYesNo`, `resolveProjectPath`
76-
77-
## Scripts Index (`scripts/`)
78-
79-
- `scripts/postinstall.js` — NPM post-install hook. Creates `~/.code-container/` structure, copies default Dockerfile, and creates `DOCKER_FLAGS.txt` and `DOCKER_RUN_FLAGS.txt`.
80-
- `scripts/migrate.sh` — Migrates config files from old shell script location to new `~/.code-container/configs/`.
81-
- `scripts/cleanup.sh` — Removes old config files from project root after migration.
82-
83-
## Storage Structure
84-
85-
All user data stored in `~/.code-container/`:
86-
87-
```
88-
~/.code-container/
89-
├── configs/ # Harness configs (mounted to containers)
90-
│ ├── .claude/
91-
│ ├── .claude.json
92-
│ ├── .codex/
93-
│ ├── .copilot/
94-
│ ├── .gemini/
95-
│ ├── .local/
96-
│ └── .opencode/
97-
├── Dockerfile # Custom Dockerfile
98-
├── MOUNTS.txt # Additional mount points
99-
├── DOCKER_FLAGS.txt # Docker flags for both run and exec
100-
├── DOCKER_RUN_FLAGS.txt # Docker flags for run only
101-
└── settings.json # Internal settings
102-
```
103-
104-
## CLI Commands
105-
106-
- `container [path]` — Run container for project (`commands.ts:runContainer`)
107-
- `container run [path] [-- DOCKER_FLAGS]` — Run container with optional Docker flags
108-
- `container build` — Build Docker image (`commands.ts:buildImage`)
109-
- `container init` — Initialize config files (`commands.ts:init`)
110-
- `container stop` — Stop container (`commands.ts:stopContainerForProject`)
111-
- `container remove` — Remove container (`commands.ts:removeContainerForProject`)
112-
- `container list` — List all containers (`commands.ts:listContainers`)
113-
- `container clean` — Remove stopped containers (`commands.ts:cleanContainers`)

Dockerfile.User

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# User customizations for code-container
2+
# Add your RUN, ENV, COPY, etc. directives below.
3+
FROM code-container-base:latest

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ container init # Copy/recopy config files
9393
9494
Destructive actions are localized inside containers.
9595
- You can let your harness run with full permissions
96-
- To configure your harness to run without permissions, see [`Permissions.md`](Permissions.md).
96+
- To configure your harness to run without permissions, see [`Permissions.md`](docs/Permissions.md).
9797
9898
### Customization
9999
@@ -106,12 +106,16 @@ Destructive actions are localized inside containers.
106106
107107
Easily add your own tooling & mount points.
108108
109-
**Adding tools/packages**: Edit `~/.code-container/Dockerfile` and rebuild:
109+
**Adding tools/packages**: Edit `~/.code-container/Dockerfile.User` and rebuild:
110110
111111
```dockerfile
112+
FROM code-container-base:latest
113+
112114
RUN apt-get update && apt-get install -y postgresql-client redis-tools
113115
```
114116
117+
> **Deprecation Notice**: `~/.code-container/Dockerfile` is deprecated and no longer used. If you previously customized this file, migrate your custom `RUN` commands to `~/.code-container/Dockerfile.User`.
118+
115119
**Adding mount points**: Edit `~/.code-container/MOUNTS.txt` and reinitialize containers:
116120

117121
```
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Setup: Do for the user, one step at a time.
2222
```bash
2323
container init
2424
```
25-
3. Setup is done. Now, read `~/.code-container/Dockerfile`, which is the default packaged Dockerfile. Provide a brief list of included packages to the user. Then, ask user if they would like to add more packages into container environment. If yes, see `Add Packages/Dependencies` section below.
25+
3. Setup is done. Now, read the `Dockerfile` and the user's `~/.code-container/Dockerfile.User` if exists. Provide a brief list of included packages to the user. Then, ask user if they would like to add more packages into container environment. If yes, see `Add Packages/Dependencies` section below.
2626
4. Build the Docker image for the user. Before you build, tell the user that building the image may take up to 5 minutes.
2727
```bash
2828
container build
@@ -60,19 +60,23 @@ All container data is stored in `~/.code-container/`:
6060
│ ├── .gemini/
6161
│ ├── .local/
6262
│ └── .opencode/
63-
├── Dockerfile # Custom Dockerfile
63+
├── Dockerfile.User # User customizations layered on base image
6464
├── MOUNTS.txt # Additional mount points
6565
├── DOCKER_FLAGS.txt # Additional docker run flags
6666
└── settings.json # Internal settings
6767
```
6868

6969
## Customization
7070

71-
### Add Packages/Dependencies (Dockerfile)
71+
### Add Packages/Dependencies (Dockerfile.User)
7272

73-
Add new tools by extending the RUN commands in `~/.code-container/Dockerfile`:
73+
> **Deprecation Notice**: `~/.code-container/Dockerfile` is deprecated and no longer used. If the user previously customized this file, offer to migrate their custom `RUN` commands to `~/.code-container/Dockerfile.User`.
74+
75+
Add new tools by editing `~/.code-container/Dockerfile.User`:
7476

7577
```dockerfile
78+
FROM code-container-base:latest
79+
7680
# System packages (Ubuntu/Debian)
7781
RUN apt-get update && apt-get install -y \
7882
postgresql-client \
@@ -126,6 +130,6 @@ Each line is parsed like a shell command. Empty lines and lines starting with `#
126130

127131
## Harness Permissions
128132

129-
If the user asks you to configure harnesses to run without permission prompts inside `container`, read and follow instructions in [Permissions.md](/Permissions.md).
133+
If the user asks you to configure harnesses to run without permission prompts inside `container`, read and follow instructions in [Permissions.md](/docs/Permissions.md).
130134

131135
Note: Modify the configuration files inside `~/.code-container/configs` only.
File renamed without changes.

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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "code-container",
3-
"version": "2.3.0",
3+
"version": "2.4.0",
44
"description": "Manage isolated Docker containers for running coding tools on different projects",
55
"main": "dist/main.js",
66
"bin": {
@@ -9,7 +9,8 @@
99
"files": [
1010
"dist",
1111
"scripts",
12-
"Dockerfile"
12+
"Dockerfile",
13+
"Dockerfile.User"
1314
],
1415
"scripts": {
1516
"build": "tsc && chmod u+x dist/main.js",

scripts/postinstall.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ const os = require("os");
66

77
const APPDATA_DIR = path.join(os.homedir(), ".code-container");
88
const CONFIGS_DIR = path.join(APPDATA_DIR, "configs");
9-
const DOCKERFILE_PATH = path.join(APPDATA_DIR, "Dockerfile");
9+
const USER_DOCKERFILE_PATH = path.join(APPDATA_DIR, "Dockerfile.User");
10+
const PACKAGED_USER_DOCKERFILE = path.join(__dirname, "..", "Dockerfile.User");
1011
const FLAGS_PATH = path.join(APPDATA_DIR, "DOCKER_FLAGS.txt");
1112
const RUN_FLAGS_PATH = path.join(APPDATA_DIR, "DOCKER_RUN_FLAGS.txt");
12-
const PACKAGED_DOCKERFILE = path.join(__dirname, "..", "Dockerfile");
1313

1414
if (!fs.existsSync(APPDATA_DIR)) {
1515
fs.mkdirSync(APPDATA_DIR, { recursive: true, mode: 0o700 });
@@ -19,8 +19,8 @@ if (!fs.existsSync(CONFIGS_DIR)) {
1919
fs.mkdirSync(CONFIGS_DIR, { recursive: true, mode: 0o700 });
2020
}
2121

22-
if (!fs.existsSync(DOCKERFILE_PATH)) {
23-
fs.copyFileSync(PACKAGED_DOCKERFILE, DOCKERFILE_PATH);
22+
if (!fs.existsSync(USER_DOCKERFILE_PATH)) {
23+
fs.copyFileSync(PACKAGED_USER_DOCKERFILE, USER_DOCKERFILE_PATH);
2424
}
2525

2626
if (!fs.existsSync(FLAGS_PATH)) {

0 commit comments

Comments
 (0)