# Development Container Setup

This project includes a development container configuration that provides a fully configured development environment using Docker containers.

## Prerequisites

- [Docker](https://www.docker.com/get-started) installed and running
- [Visual Studio Code](https://code.visualstudio.com/) with the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)

## Getting Started

1. **Open in Dev Container**:
   - Open the project in VS Code
   - When prompted, click "Reopen in Container" or use Command Palette: `Dev Containers: Reopen in Container`
   - The first time will take longer as it builds the container

2. **Alternative Methods**:
   - Use Command Palette: `Dev Containers: Open Folder Locally in Container`
   - Or click the green "Open Remote Window" button in the bottom-left and select "Reopen in Container"

## What's Included

### Development Tools

- **Node.js 20** with pnpm package manager
- **TypeScript** and **ESLint** for code quality
- **Prettier** for code formatting
- **Jest** and **Playwright** for testing
- **Git** for version control
- **GitHub CLI** for repository management

### Project Dependencies

- **HandBrake CLI** for video processing
- **FFmpeg** for media handling
- **SQLite3** for database operations
- **Docker-in-Docker** for container operations

### VS Code Extensions

- TypeScript and JavaScript support
- Tailwind CSS IntelliSense
- ESLint and Prettier integration
- Playwright testing tools
- GitHub Copilot (if available)
- Test Explorer integration

## Development Workflow

Once the container is running:

```bash
# Install dependencies (already done in postCreateCommand)
pnpm install

# Start development servers
pnpm run dev

# Run tests
pnpm run test

# Lint code
pnpm run lint

# Format code
pnpm run format
```

## Port Forwarding

The following ports are automatically forwarded:

- **3000**: Next.js web application
- **3001**: NestJS API service
- **9229**: Node.js debugger

## File Mounting

- **Workspace**: Full project directory is mounted for live editing
- **Data Directory**: SQLite database files persist between sessions
- **pnpm Store**: Package cache is persisted for faster installs

## Customization

### Adding Extensions

Edit `.devcontainer/devcontainer.json` and add extensions to the `customizations.vscode.extensions` array.

### Modifying Environment

Add environment variables in the `containerEnv` section of `devcontainer.json`.

### Installing Additional Tools

Add packages to the Dockerfile or use the features system in `devcontainer.json`.

## Troubleshooting

### Container Won't Start

- Ensure Docker is running
- Check available disk space
- Try rebuilding: `Dev Containers: Rebuild Container`

### Port Conflicts

- Modify port forwarding in `devcontainer.json`
- Check if ports are already in use on host

### Performance Issues

- Ensure adequate RAM allocation for Docker
- Consider using Docker Desktop settings to increase resources

### Permission Issues

- Files are owned by the `node` user in the container
- Use `sudo` if needed for system-level operations

## Advanced Configuration

### Custom Dockerfile

The included Dockerfile extends the official Node.js dev container image. Modify it to add custom tools or configurations.

### Multiple Configurations

Create multiple dev container configurations by adding more files in the `.devcontainer` directory.

### Remote Development

This setup works with GitHub Codespaces and other remote development environments.

## Contributing

When making changes to the dev container setup:

1. Test the configuration thoroughly
2. Update this README if adding new features
3. Consider the impact on different development environments

## Support

For issues with the dev container setup:

1. Check the VS Code Dev Containers documentation
2. Review Docker and container logs
3. Ensure all prerequisites are met
