diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..e017b2fc --- /dev/null +++ b/.devcontainer/Dockerfile @@ -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 diff --git a/.devcontainer/README.md b/.devcontainer/README.md new file mode 100644 index 00000000..f86f7cc0 --- /dev/null +++ b/.devcontainer/README.md @@ -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 +``` + +## 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/) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..f4e9749c --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -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" + } +} diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh new file mode 100644 index 00000000..05637629 --- /dev/null +++ b/.devcontainer/post-create.sh @@ -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 "" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..60d5d267 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,24 @@ + - name: Setup Node.js environment + uses: actions/setup-node@v3.9.1 + with: + # Set always-auth in npmrc. + always-auth: # optional, default is false + # Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0. + node-version: # optional + # File containing the version Spec of the version to use. Examples: .nvmrc, .node-version, .tool-versions. + node-version-file: # optional + # Target architecture for Node to use. Examples: x86, x64. Will use system architecture by default. + architecture: # optional + # Set this option if you want the action to check for the latest available version that satisfies the version spec. + check-latest: # optional + # Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file, and set up auth to read in from env.NODE_AUTH_TOKEN. + registry-url: # optional + # Optional scope for authenticating against scoped registries. Will fall back to the repository owner when using the GitHub Packages registry (https://npm.pkg.github.com/). + scope: # optional + # Used to pull node distributions from node-versions. Since there's a default, this is typically not supplied by the user. When running this action on github.com, the default value is sufficient. When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting. + token: # optional, default is ${{ github.server_url == 'https://github.com' && github.token || '' }} + # Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm. + cache: # optional + # Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc. Supports wildcards or a list of file names for caching multiple dependencies. + cache-dependency-path: # optional +