Skip to content

Commit ea411ad

Browse files
authored
Merge pull request #46 from Chaosbit/copilot/fix-45
[Feature]: Add .NET Backend with User Authentication and Data Synchronization
2 parents 3ca3143 + 6edb586 commit ea411ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+7889
-968
lines changed

.devcontainer/README.md

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
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+
```

.devcontainer/devcontainer.json

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"name": "Workout Timer PWA",
3+
"image": "mcr.microsoft.com/devcontainers/javascript-node:18",
4+
"customizations": {
5+
"vscode": {
6+
"extensions": [
7+
"ms-vscode.vscode-json",
8+
"bradlc.vscode-tailwindcss",
9+
"ms-dotnettools.csharp",
10+
"ms-dotnettools.vscode-dotnet-runtime",
11+
"ms-vscode.vscode-eslint",
12+
"esbenp.prettier-vscode",
13+
"ms-vscode.test-adapter-converter",
14+
"hbenl.vscode-test-explorer",
15+
"ms-playwright.playwright",
16+
"ms-vscode.vscode-jest",
17+
"HashiCorp.terraform",
18+
"ms-vscode.azurecli",
19+
"ms-azuretools.vscode-azureresourcegroups",
20+
"ms-azuretools.vscode-azureappservice"
21+
],
22+
"settings": {
23+
"terminal.integrated.defaultProfile.linux": "bash",
24+
"editor.formatOnSave": true,
25+
"editor.defaultFormatter": "esbenp.prettier-vscode",
26+
"javascript.preferences.includePackageJsonAutoImports": "on",
27+
"typescript.preferences.includePackageJsonAutoImports": "on",
28+
"jest.autoRun": "off",
29+
"jest.showCoverageOnLoad": true
30+
}
31+
}
32+
},
33+
"forwardPorts": [8000, 5000, 3000, 15888],
34+
"portsAttributes": {
35+
"8000": {
36+
"label": "PWA Development Server",
37+
"protocol": "http"
38+
},
39+
"5000": {
40+
"label": ".NET Backend API",
41+
"protocol": "http"
42+
},
43+
"3000": {
44+
"label": "Alternative Dev Server",
45+
"protocol": "http"
46+
},
47+
"15888": {
48+
"label": "Aspire Dashboard",
49+
"protocol": "https"
50+
}
51+
},
52+
"postCreateCommand": "bash .devcontainer/post-create.sh",
53+
"features": {
54+
"ghcr.io/devcontainers/features/dotnet:1": {
55+
"version": "8.0"
56+
},
57+
"ghcr.io/devcontainers/features/git:1": {},
58+
"ghcr.io/devcontainers/features/github-cli:1": {},
59+
"ghcr.io/devcontainers/features/terraform:1": {
60+
"version": "latest"
61+
},
62+
"ghcr.io/devcontainers/features/azure-cli:1": {
63+
"version": "latest"
64+
},
65+
"ghcr.io/devcontainers/features/common-utils:2": {
66+
"installZsh": true,
67+
"installOhMyZsh": true,
68+
"upgradePackages": true,
69+
"username": "vscode",
70+
"uid": "1000",
71+
"gid": "1000"
72+
}
73+
}
74+
}

.devcontainer/post-create.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
echo "Setting up Workout Timer PWA development environment..."
6+
7+
# Install additional packages
8+
sudo apt-get update
9+
sudo apt-get install -y sqlite3 python3 python3-pip
10+
11+
# Install global npm packages
12+
sudo npm install -g serve http-server jest cypress
13+
14+
# Install Playwright dependencies
15+
npx playwright install-deps
16+
17+
# Install npm dependencies
18+
echo "Installing npm dependencies..."
19+
npm install
20+
21+
# Setup backend
22+
if [ -d "backend" ]; then
23+
echo "Setting up .NET backend..."
24+
cd backend
25+
dotnet restore
26+
cd ..
27+
fi
28+
29+
# Setup permissions
30+
sudo chown -R vscode:vscode /workspaces/WorkoutApp
31+
32+
echo "Development environment setup complete!"

0 commit comments

Comments
 (0)