Skip to content
Open

pull #62

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This Dockerfile extends the universal dev container with custom setup
# For most use cases, the devcontainer.json features are sufficient

FROM mcr.microsoft.com/devcontainers/universal:2

# Install additional system tools
RUN apt-get update && apt-get install -y \
build-essential \
curl \
wget \
git \
vim \
nano \
htop \
tmux \
jq \
unzip \
&& rm -rf /var/lib/apt/lists/*

# Create workspace directories
RUN mkdir -p /workspace/{go,python,node,java} && \
chown -R node:node /workspace

USER node
WORKDIR /home/node

# Set up shell environment
RUN echo 'export PATH=$PATH:/home/node/go/bin' >> ~/.bashrc && \
echo 'export GOPATH=/home/node/go' >> ~/.bashrc
169 changes: 169 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
# Development Container Setup

This directory contains configuration for a comprehensive development environment supporting multiple languages and tools.

## Quick Start

### Prerequisites
- Docker Desktop or Docker Engine
- Visual Studio Code with Remote - Containers extension

### Launch Dev Container
1. Open the project in VS Code
2. Press `Ctrl+Shift+P` (or `Cmd+Shift+P` on Mac)
3. Select "Dev Containers: Reopen in Container"
4. Wait for the container to build and setup

## Included Runtimes & Tools

### Languages
- **Node.js** 20 LTS - JavaScript/TypeScript development
- **Python** 3.11 - Python development with linting & testing tools
- **Go** 1.23 - Go development with linters
- **Java** 21 - Java development with Maven & Gradle
- **Docker** - Docker-outside-Docker for container operations

### Development Tools
- **GitHub CLI** - GitHub automation and management
- **npm, yarn, pnpm** - JavaScript package managers
- **Maven & Gradle** - Java build tools
- **git** - Version control

### Python Packages (Pre-installed)
- black - Code formatter
- pylint - Linter
- pytest - Testing framework
- flake8 - Style guide enforcement
- pytest-cov - Code coverage
- mypy - Type checker

### VS Code Extensions
- TypeScript/JavaScript support
- Python extension pack
- Go extension
- Java extension pack
- YAML support
- Prettier code formatter
- GitHub Copilot
- Remote containers

## Forwarded Ports

| Port | Service | Label |
|------|---------|-------|
| 3000 | Application | App server |
| 5000 | Flask/API | Python API |
| 8000 | Dev Server | Node dev server |
| 8080 | HTTP | Web server |
| 8443 | HTTPS | Secure web server |
| 9000 | Java Debug | Debug port |
| 27017 | MongoDB | NoSQL database |
| 5432 | PostgreSQL | SQL database |
| 6379 | Redis | Cache/session store |

## Environment Variables

```bash
NODE_ENV=development
PYTHONUNBUFFERED=1
GOPATH=/home/node/go
TZ=UTC
```

## File Mounts

- `~/.ssh` → `/home/node/.ssh` (read-only)
- `~/.gitconfig` → `/home/node/.gitconfig` (read-only)
- `~/.m2` → `/home/node/.m2` (Maven cache)

## Common Commands

### Node.js
```bash
node --version
npm install
npm run dev
npm test
```

### Python
```bash
python --version
pip install -r requirements.txt
python -m pytest
python -m black .
python -m pylint *.py
```

### Go
```bash
go version
go mod tidy
go build ./...
golangci-lint run ./...
```

### Java
```bash
java -version
mvn clean install
gradle build
```

### Docker
```bash
docker ps
docker build .
docker run -it <image>
```

## Customization

### Adding VS Code Extensions
Edit `.devcontainer/devcontainer.json` and add to the `extensions` array:
```json
"customizations": {
"vscode": {
"extensions": [
"publisher.extension-name"
]
}
}
```

### Adding System Packages
Update `.devcontainer/Dockerfile` RUN command:
```dockerfile
RUN apt-get update && apt-get install -y \
package-name \
&& rm -rf /var/lib/apt/lists/*
```

### Adding Environment Variables
Edit `devcontainer.json` `remoteEnv` section or update `post-create.sh`

## Troubleshooting

### Container won't start
- Check Docker is running: `docker ps`
- Rebuild container: `Dev Containers: Rebuild Container`

### Port conflicts
- Modify `forwardPorts` in `devcontainer.json`
- Or use `portsAttributes` to change auto-forward behavior

### Permission issues
- Ensure `/workspace` directories are writable
- Check mounted volumes have correct permissions

### Git credentials not working
- Verify `~/.gitconfig` exists and is mounted
- Consider using SSH keys from `~/.ssh`

## Resources

- [Dev Containers Documentation](https://containers.dev/)
- [Node.js LTS](https://nodejs.org/)
- [Python 3.11](https://www.python.org/)
- [Go 1.23](https://go.dev/)
- [Java 21](https://www.oracle.com/java/)
130 changes: 130 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{
"image": "mcr.microsoft.com/devcontainers/universal:2",
"features": {
"ghcr.io/devcontainers/features/node:1": {
"version": "20"
},
"ghcr.io/devcontainers/features/python:1": {
"version": "3.11"
},
"ghcr.io/devcontainers/features/go:1": {
"version": "1.23"
},
"ghcr.io/devcontainers/features/java:1": {
"version": "21",
"installMaven": true,
"installGradle": true
},
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
},
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.vscode-typescript-next",
"ms-python.python",
"golang.go",
"redhat.vscode-yaml",
"ms-vscode.makefile-tools",
"GitHub.copilot",
"esbenp.prettier-vscode",
"ms-vscode.extension-pack-for-python",
"Extension.ms-vscode-remote-remote-containers",
"vscjava.extension-pack-for-java",
"redhat.java",
"vscjava.vscode-maven",
"vscjava.vscode-gradle",
"ms-python.vscode-pylance",
"golang.go-nightly"
],
"settings": {
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[python]": {
"editor.defaultFormatter": "ms-python.python",
"editor.formatOnSave": true
},
"[go]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
},
"[java]": {
"editor.defaultFormatter": "redhat.java",
"editor.formatOnSave": true
},
"java.server.launchMode": "Standard",
"java.import.maven.exclusions": ["**/node_modules/**", "**/.m2/**"],
"java.configuration.maven.globalSettings": "/home/node/.m2/settings.xml"
}
}
},
"forwardPorts": [
3000,
5000,
8000,
8080,
8443,
9000,
27017,
5432,
6379
],
"portsAttributes": {
"3000": {
"label": "Application",
"onAutoForward": "notify"
},
"5000": {
"label": "Flask/API",
"onAutoForward": "notify"
},
"8000": {
"label": "Development Server",
"onAutoForward": "notify"
},
"8080": {
"label": "HTTP",
"onAutoForward": "notify"
},
"8443": {
"label": "HTTPS",
"onAutoForward": "notify"
},
"9000": {
"label": "Java Debug",
"onAutoForward": "silent"
},
"27017": {
"label": "MongoDB",
"onAutoForward": "silent"
},
"5432": {
"label": "PostgreSQL",
"onAutoForward": "silent"
},
"6379": {
"label": "Redis",
"onAutoForward": "silent"
}
},
"postCreateCommand": "bash .devcontainer/post-create.sh",
"remoteUser": "node",
"mounts": [
"source=${localEnv:HOME}/.ssh,target=/home/node/.ssh,readonly",
"source=${localEnv:HOME}/.gitconfig,target=/home/node/.gitconfig,readonly",
"source=${localEnv:HOME}/.m2,target=/home/node/.m2"
],
"remoteEnv": {
"NODE_ENV": "development",
"PYTHONUNBUFFERED": "1",
"GOPATH": "/home/node/go"
},
"containerEnv": {
"TZ": "UTC"
}
}
58 changes: 58 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash
set -e

echo "🚀 Starting post-create setup..."

# Update system packages
echo "📦 Updating system packages..."
sudo apt-get update
sudo apt-get upgrade -y

# Node.js setup
echo "📦 Setting up Node.js..."
npm install -g npm@latest
npm install -g yarn pnpm

# Python setup
echo "🐍 Setting up Python..."
pip install --upgrade pip setuptools wheel
pip install black pylint pytest flake8 pytest-cov mypy

# Go setup
echo "🐹 Setting up Go..."
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install golang.org/x/tools/...@latest

# Java setup
echo "☕ Setting up Java..."
mkdir -p ~/.m2

# Git setup
echo "🔧 Configuring Git..."
git config --global core.editor "nano"
git config --global pull.rebase false

# Docker setup
echo "🐳 Verifying Docker..."
docker --version

# Create workspace directories
echo "📁 Creating workspace directories..."
mkdir -p /workspace/go
mkdir -p /workspace/python
mkdir -p /workspace/node
mkdir -p /workspace/java

echo "✅ Post-create setup complete!"
echo ""
echo "Available tools:"
echo " Node.js: $(node --version)"
echo " NPM: $(npm --version)"
echo " Yarn: $(yarn --version)"
echo " Python: $(python --version)"
echo " Go: $(go version)"
echo " Java: $(java -version 2>&1 | head -n 1)"
echo " Maven: $(mvn --version 2>&1 | head -n 1)"
echo " Gradle: $(gradle --version 2>&1 | head -n 1)"
echo " GitHub CLI: $(gh --version 2>&1 | head -n 1)"
echo ""
Loading
Loading