Skip to content

Commit 4bd2682

Browse files
committed
Optimize devcontainer for faster startup
- Disabled package upgrades (upgradePackages: false) - Removed heavy features: kubectl-helm-minikube, sshd - Changed Git to os-provided version for faster builds - Removed unnecessary packages from Dockerfile - Removed docker-compose.yml for simpler single-container setup - Streamlined postCreateCommand - Removed heavy VS Code extensions - Added setup-optional-tools.sh for on-demand tool installation - Added dependabot.yml for dependency management Estimated startup time reduced from 4-6 minutes to 1-2 minutes. Signed-off-by: Ihor Dvoretskyi <ihor@linux.com>
1 parent e60ceb5 commit 4bd2682

File tree

6 files changed

+101
-52
lines changed

6 files changed

+101
-52
lines changed

.devcontainer/Dockerfile

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
FROM mcr.microsoft.com/devcontainers/base:ubuntu-24.04
22

3-
# Install essential packages and set up directories
4-
# hadolint ignore=DL3008
53
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
64
&& apt-get -y install --no-install-recommends \
75
curl \
86
wget \
97
jq \
108
build-essential \
11-
openssh-server \
12-
tcl \
139
&& apt-get clean -y \
14-
&& rm -rf /var/lib/apt/lists/* \
15-
&& mkdir -p /run/sshd \
16-
&& mkdir -p /home/vscode/.ssh \
17-
&& chown -R vscode:vscode /home/vscode/.ssh \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
RUN mkdir -p /home/vscode/.ssh \
13+
&& chown -R vscode:vscode /home/vscode \
1814
&& chmod 700 /home/vscode/.ssh

.devcontainer/devcontainer.json

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
"ghcr.io/devcontainers/features/common-utils:2": {
1010
"installZsh": true,
1111
"username": "vscode",
12-
"upgradePackages": true
12+
"upgradePackages": false
1313
},
1414
"ghcr.io/devcontainers/features/git:1": {
15-
"version": "latest",
15+
"version": "os-provided",
1616
"ppa": false
1717
},
1818
"ghcr.io/devcontainers/features/node:1": {
@@ -25,14 +25,6 @@
2525
"moby": true,
2626
"dockerDashComposeVersion": "v2"
2727
},
28-
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {
29-
"version": "latest",
30-
"helm": "latest",
31-
"minikube": "latest"
32-
},
33-
"ghcr.io/devcontainers/features/sshd:1": {
34-
"version": "latest"
35-
},
3628
"ghcr.io/devcontainers/features/github-cli:1": {
3729
"version": "latest"
3830
}
@@ -43,9 +35,7 @@
4335
"ms-azuretools.vscode-docker",
4436
"github.copilot",
4537
"github.copilot-chat",
46-
"redhat.vscode-yaml",
47-
"ms-kubernetes-tools.vscode-kubernetes-tools",
48-
"blinksh.blink-fs"
38+
"redhat.vscode-yaml"
4939
],
5040
"settings": {
5141
"editor.formatOnSave": true,
@@ -57,8 +47,6 @@
5747
}
5848
}
5949
},
60-
"forwardPorts": [22],
61-
"postCreateCommand": "npm install -g @anthropic-ai/claude-code@latest && echo '🚀 Development environment ready! Docker, Kubernetes (Minikube), Claude Code, and SSH are configured.' && sudo service ssh start",
62-
"postStartCommand": "sudo service ssh restart",
50+
"postCreateCommand": "echo 'Development environment ready'",
6351
"remoteUser": "vscode"
6452
}

.devcontainer/docker-compose.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
echo "Installing optional development tools..."
6+
7+
# Uncomment if needed:
8+
# npm install -g @anthropic-ai/claude-code@latest
9+
10+
# Uncomment if needed:
11+
# pip3 install --user black pylint pytest
12+
13+
echo "Optional tools installation complete"

.github/dependabot.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Keep devcontainer dependencies up to date
2+
version: 2
3+
updates:
4+
# Monitor GitHub Actions
5+
- package-ecosystem: "github-actions"
6+
directory: "/"
7+
schedule:
8+
interval: "weekly"
9+
labels:
10+
- "dependencies"
11+
- "github-actions"
12+
13+
# Monitor Docker base images
14+
- package-ecosystem: "docker"
15+
directory: "/.devcontainer"
16+
schedule:
17+
interval: "weekly"
18+
labels:
19+
- "dependencies"
20+
- "docker"

README.md

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,79 @@
33
[![CI](https://github.com/idvoretskyi/dev/actions/workflows/ci.yml/badge.svg)](https://github.com/idvoretskyi/dev/actions/workflows/ci.yml)
44
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/idvoretskyi/dev)
55

6-
This repository serves as a default generic GitHub Codespace template.
6+
This repository serves as an optimized GitHub Codespaces template for general development workflows.
77

88
## Features
99

1010
- Base image: Ubuntu 24.04
11-
- Pre-installed development tools
12-
- VS Code extensions for productivity
13-
- Configured with sensible defaults
11+
- Essential development tools:
12+
- Git (OS-provided)
13+
- Node.js LTS
14+
- Docker-in-Docker
15+
- GitHub CLI
16+
- Zsh with common utilities
17+
- VS Code extensions:
18+
- Docker support
19+
- GitHub Copilot
20+
- YAML support
21+
22+
## Performance Optimizations
23+
24+
The devcontainer is optimized for fast startup:
25+
26+
- Disabled package upgrades during build
27+
- Removed heavy features (kubectl, helm, minikube, sshd)
28+
- Removed unnecessary Docker packages
29+
- Minimal postCreateCommand
30+
- Essential VS Code extensions only
31+
32+
Estimated startup time: 1-2 minutes
1433

1534
## Usage
1635

36+
### GitHub Codespaces
1737
1. Click "Code" button on the GitHub repository
1838
2. Select "Create codespace on main"
1939
3. Wait for the environment to build
20-
4. Start coding!
2140

22-
## Customization
41+
### VS Code Local Dev Containers
42+
1. Clone this repository
43+
2. Open in VS Code
44+
3. Click "Reopen in Container" when prompted
45+
46+
## Using as a Template
47+
48+
### Method 1: GitHub Template
49+
Click "Use this template" button to create a new repository
50+
51+
### Method 2: Copy Configuration
52+
```bash
53+
cp -r .devcontainer /path/to/your/project/
54+
```
55+
56+
### Customization
57+
58+
Edit `.devcontainer/devcontainer.json` to add features:
59+
60+
```json
61+
{
62+
"features": {
63+
"ghcr.io/devcontainers/features/python:1": {
64+
"version": "3.11"
65+
}
66+
},
67+
"postCreateCommand": "pip install -r requirements.txt"
68+
}
69+
```
70+
71+
## Optional Tools
2372

24-
You can customize this environment by:
73+
Install additional tools as needed:
74+
```bash
75+
bash .devcontainer/setup-optional-tools.sh
76+
```
2577

26-
- Modifying `.devcontainer/devcontainer.json` to add VS Code extensions or settings
27-
- Editing `.devcontainer/Dockerfile` to install additional packages
28-
- Updating `.devcontainer/docker-compose.yml` to add services like databases
78+
Edit the script to customize which tools to install.
2979

3080
## License
3181

0 commit comments

Comments
 (0)