|
| 1 | +# Dev Container Setup |
| 2 | + |
| 3 | +This repository includes a VS Code Dev Container configuration that provides a consistent development environment for the Workout Timer PWA project. |
| 4 | + |
| 5 | +## What's Included |
| 6 | + |
| 7 | +### Development Environment |
| 8 | +- **Node.js 18**: For frontend development and testing |
| 9 | +- **.NET 8 SDK**: For backend API development |
| 10 | +- **Git & GitHub CLI**: For version control operations |
| 11 | +- **Terraform**: For infrastructure as code management |
| 12 | +- **Azure CLI**: For Azure cloud deployments |
| 13 | +- **Python 3**: For development scripts and utilities |
| 14 | +- **SQLite**: For local database development |
| 15 | + |
| 16 | +### VS Code Extensions |
| 17 | +- **C# Dev Kit**: For .NET backend development |
| 18 | +- **ESLint & Prettier**: For code linting and formatting |
| 19 | +- **Jest Test Explorer**: For running and debugging unit tests |
| 20 | +- **Playwright**: For end-to-end testing |
| 21 | +- **Tailwind CSS**: For CSS IntelliSense |
| 22 | +- **Terraform**: For infrastructure as code support |
| 23 | +- **Azure CLI**: For Azure cloud integration |
| 24 | +- **Azure Resource Groups**: For Azure resource management |
| 25 | + |
| 26 | +### Development Tools |
| 27 | +- **Jest**: For unit testing (globally installed) |
| 28 | +- **Cypress**: For e2e testing |
| 29 | +- **Serve & HTTP-Server**: For local development servers |
| 30 | +- **Playwright**: Browser automation for testing |
| 31 | + |
| 32 | +## Getting Started |
| 33 | + |
| 34 | +### Prerequisites |
| 35 | +- **Docker**: Make sure Docker Desktop is installed and running |
| 36 | +- **VS Code**: With the Dev Containers extension installed |
| 37 | + |
| 38 | +### Using the Dev Container |
| 39 | + |
| 40 | +1. **Open the Repository** |
| 41 | + ```bash |
| 42 | + git clone https://github.com/Chaosbit/WorkoutApp |
| 43 | + cd WorkoutApp |
| 44 | + ``` |
| 45 | + |
| 46 | +2. **Start Dev Container** |
| 47 | + - Open VS Code in the repository folder |
| 48 | + - Press `Ctrl/Cmd + Shift + P` to open command palette |
| 49 | + - Type "Dev Containers: Reopen in Container" |
| 50 | + - Select the command and wait for container to build |
| 51 | + |
| 52 | +3. **Verify Setup** |
| 53 | + ```bash |
| 54 | + # Check Node.js |
| 55 | + node --version |
| 56 | + |
| 57 | + # Check .NET |
| 58 | + dotnet --version |
| 59 | + |
| 60 | + # Check Terraform |
| 61 | + terraform --version |
| 62 | + |
| 63 | + # Check Azure CLI |
| 64 | + az --version |
| 65 | + |
| 66 | + # Install dependencies |
| 67 | + npm install |
| 68 | + cd backend && dotnet restore && cd .. |
| 69 | + ``` |
| 70 | + |
| 71 | +## Development Workflow |
| 72 | + |
| 73 | +### Frontend Development |
| 74 | +```bash |
| 75 | +# Run development server |
| 76 | +python -m http.server 8000 |
| 77 | + |
| 78 | +# Run unit tests |
| 79 | +npm run test:unit |
| 80 | + |
| 81 | +# Run e2e tests |
| 82 | +npm run test:e2e |
| 83 | + |
| 84 | +# Run all tests |
| 85 | +npm run test:all |
| 86 | +``` |
| 87 | + |
| 88 | +### Backend Development |
| 89 | +```bash |
| 90 | +# Navigate to backend |
| 91 | +cd backend |
| 92 | + |
| 93 | +# Run the API |
| 94 | +dotnet run |
| 95 | + |
| 96 | +# Run backend tests |
| 97 | +dotnet test |
| 98 | +``` |
| 99 | + |
| 100 | +### Infrastructure Management |
| 101 | +```bash |
| 102 | +# Navigate to terraform directory |
| 103 | +cd terraform |
| 104 | + |
| 105 | +# Initialize Terraform |
| 106 | +terraform init |
| 107 | + |
| 108 | +# Plan infrastructure changes |
| 109 | +terraform plan |
| 110 | + |
| 111 | +# Apply infrastructure changes |
| 112 | +terraform apply |
| 113 | + |
| 114 | +# Check Azure resources |
| 115 | +az account show |
| 116 | +az group list |
| 117 | +``` |
| 118 | + |
| 119 | +## Port Forwarding |
| 120 | + |
| 121 | +The container automatically forwards these ports: |
| 122 | +- **8000**: PWA Development Server |
| 123 | +- **5000**: .NET Backend API |
| 124 | +- **3000**: Alternative Dev Server |
| 125 | + |
| 126 | +## Container Features |
| 127 | + |
| 128 | +### Post-Create Setup |
| 129 | +The container automatically runs: |
| 130 | +```bash |
| 131 | +bash .devcontainer/post-create.sh |
| 132 | +``` |
| 133 | + |
| 134 | +This script: |
| 135 | +- Installs additional development tools (sqlite3, python3, global npm packages) |
| 136 | +- Installs Playwright dependencies |
| 137 | +- Runs `npm install` and `dotnet restore` |
| 138 | +- Sets up proper file permissions |
| 139 | + |
| 140 | +### Environment Variables |
| 141 | +- `NODE_ENV=development` |
| 142 | +- `DOTNET_CLI_TELEMETRY_OPTOUT=1` |
| 143 | +- `DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1` |
| 144 | + |
| 145 | +## Troubleshooting |
| 146 | + |
| 147 | +### Container Build Issues |
| 148 | +If the container fails to build: |
| 149 | +1. Check Docker Desktop is running |
| 150 | +2. Try rebuilding: `Dev Containers: Rebuild Container` |
| 151 | +3. Clear Docker cache if needed |
| 152 | +4. If you see Microsoft repository errors, ensure you're using the latest devcontainer features |
| 153 | + |
| 154 | +**Common Error Fix**: If you encounter user permission errors like: |
| 155 | +``` |
| 156 | +Status 500: {"cause":"no matching entries in passwd file","message":"unable to find user vscode: no matching entries in passwd file","response":500} |
| 157 | +``` |
| 158 | +This has been resolved by using the proper devcontainer features configuration with `common-utils` feature that ensures the vscode user is created correctly. |
| 159 | + |
| 160 | +### Permission Issues |
| 161 | +If you encounter permission issues: |
| 162 | +```bash |
| 163 | +# Fix npm permissions |
| 164 | +sudo chown -R $USER:$GROUP ~/.npm |
| 165 | +``` |
| 166 | + |
| 167 | +### Port Conflicts |
| 168 | +If ports are already in use: |
| 169 | +1. Modify port numbers in `.devcontainer/devcontainer.json` |
| 170 | +2. Rebuild the container |
| 171 | + |
| 172 | +## Manual Setup (Alternative) |
| 173 | + |
| 174 | +If you prefer not to use Dev Containers: |
| 175 | + |
| 176 | +```bash |
| 177 | +# Install Node.js 18 |
| 178 | +curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - |
| 179 | +sudo apt-get install -y nodejs |
| 180 | + |
| 181 | +# Install .NET 8 |
| 182 | +wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb |
| 183 | +sudo dpkg -i packages-microsoft-prod.deb |
| 184 | +sudo apt-get update && sudo apt-get install -y dotnet-sdk-8.0 |
| 185 | + |
| 186 | +# Install Terraform |
| 187 | +wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg |
| 188 | +echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list |
| 189 | +sudo apt update && sudo apt install terraform |
| 190 | + |
| 191 | +# Install Azure CLI |
| 192 | +curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash |
| 193 | + |
| 194 | +# Install dependencies |
| 195 | +npm install |
| 196 | +cd backend && dotnet restore |
| 197 | +``` |
0 commit comments