|
| 1 | +# Docker Setup for Chrome DevTools Frontend |
| 2 | + |
| 3 | +This directory contains Docker configuration files for building and running the Chrome DevTools Frontend in a containerized environment. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The Docker setup uses a multi-stage build process: |
| 8 | +1. **Build Stage**: Compiles the DevTools frontend using the full development environment |
| 9 | +2. **Production Stage**: Serves only the built files using Nginx (lightweight, ~50MB final image) |
| 10 | + |
| 11 | +## Prerequisites |
| 12 | + |
| 13 | +- Docker Engine 20.10+ installed |
| 14 | +- Docker Compose v2.0+ (optional, for easier management) |
| 15 | +- At least 8GB of available disk space for the build process |
| 16 | +- 4GB+ RAM recommended for building |
| 17 | + |
| 18 | +## Quick Start |
| 19 | + |
| 20 | +### Building the Docker Image |
| 21 | + |
| 22 | +From the repository root directory: |
| 23 | + |
| 24 | +```bash |
| 25 | +# Build the Docker image |
| 26 | +docker build -f docker/Dockerfile -t devtools-frontend . |
| 27 | + |
| 28 | +# Or use docker-compose (recommended) |
| 29 | +docker-compose -f docker/docker-compose.yml build |
| 30 | +``` |
| 31 | + |
| 32 | +### Running the Container |
| 33 | + |
| 34 | +```bash |
| 35 | +# Using docker run |
| 36 | +docker run -d -p 8000:8000 --name devtools-frontend devtools-frontend |
| 37 | + |
| 38 | +# Or using docker-compose (recommended) |
| 39 | +docker-compose -f docker/docker-compose.yml up -d |
| 40 | +``` |
| 41 | + |
| 42 | +The DevTools will be available at: http://localhost:8000 |
| 43 | + |
| 44 | +### Accessing DevTools |
| 45 | + |
| 46 | +Once the container is running, open Chrome or Chromium with: |
| 47 | + |
| 48 | +```bash |
| 49 | +# macOS |
| 50 | +/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --custom-devtools-frontend=http://localhost:8000/ |
| 51 | + |
| 52 | +# Linux |
| 53 | +google-chrome --custom-devtools-frontend=http://localhost:8000/ |
| 54 | + |
| 55 | +# Windows |
| 56 | +chrome.exe --custom-devtools-frontend=http://localhost:8000/ |
| 57 | +``` |
| 58 | + |
| 59 | +## File Structure |
| 60 | + |
| 61 | +``` |
| 62 | +docker/ |
| 63 | +├── Dockerfile # Multi-stage build configuration |
| 64 | +├── .dockerignore # Files to exclude from Docker context |
| 65 | +├── nginx.conf # Nginx server configuration |
| 66 | +├── docker-compose.yml # Docker Compose configuration |
| 67 | +└── README.md # This file |
| 68 | +``` |
| 69 | + |
| 70 | +## Advanced Usage |
| 71 | + |
| 72 | +### Development Mode |
| 73 | + |
| 74 | +For development with local file changes: |
| 75 | + |
| 76 | +1. Build the project locally first: |
| 77 | +```bash |
| 78 | +npm run build |
| 79 | +``` |
| 80 | + |
| 81 | +2. Run the container with volume mount: |
| 82 | +```bash |
| 83 | +docker run -d -p 8000:8000 \ |
| 84 | + -v $(pwd)/out/Default/gen/front_end:/usr/share/nginx/html:ro \ |
| 85 | + --name devtools-frontend-dev \ |
| 86 | + devtools-frontend |
| 87 | +``` |
| 88 | + |
| 89 | +Or uncomment the volume mount in `docker-compose.yml`. |
| 90 | + |
| 91 | +### Custom Port |
| 92 | + |
| 93 | +To run on a different port: |
| 94 | + |
| 95 | +```bash |
| 96 | +# Using docker run |
| 97 | +docker run -d -p 9000:8000 devtools-frontend |
| 98 | + |
| 99 | +# Using docker-compose |
| 100 | +DEVTOOLS_PORT=9000 docker-compose -f docker/docker-compose.yml up -d |
| 101 | +``` |
| 102 | + |
| 103 | +Then update your Chrome launch command accordingly. |
| 104 | + |
| 105 | +### Building with Cache |
| 106 | + |
| 107 | +To speed up rebuilds, Docker automatically caches layers. To force a fresh build: |
| 108 | + |
| 109 | +```bash |
| 110 | +docker build -f docker/Dockerfile --no-cache -t devtools-frontend . |
| 111 | +``` |
| 112 | + |
| 113 | +### Viewing Logs |
| 114 | + |
| 115 | +```bash |
| 116 | +# Using docker |
| 117 | +docker logs devtools-frontend |
| 118 | + |
| 119 | +# Using docker-compose |
| 120 | +docker-compose -f docker/docker-compose.yml logs -f |
| 121 | +``` |
| 122 | + |
| 123 | +### Stopping the Container |
| 124 | + |
| 125 | +```bash |
| 126 | +# Using docker |
| 127 | +docker stop devtools-frontend |
| 128 | +docker rm devtools-frontend |
| 129 | + |
| 130 | +# Using docker-compose |
| 131 | +docker-compose -f docker/docker-compose.yml down |
| 132 | +``` |
| 133 | + |
| 134 | +## Troubleshooting |
| 135 | + |
| 136 | +### Build Fails |
| 137 | + |
| 138 | +If the build fails: |
| 139 | +1. Ensure you have enough disk space (8GB+ free) |
| 140 | +2. Check Docker memory limits (4GB+ recommended) |
| 141 | +3. Try building with `--no-cache` flag |
| 142 | +4. Check the build logs for specific errors |
| 143 | + |
| 144 | +### Container Won't Start |
| 145 | + |
| 146 | +1. Check if port 8000 is already in use: |
| 147 | + ```bash |
| 148 | + lsof -i :8000 # macOS/Linux |
| 149 | + netstat -an | findstr :8000 # Windows |
| 150 | + ``` |
| 151 | + |
| 152 | +2. View container logs: |
| 153 | + ```bash |
| 154 | + docker logs devtools-frontend |
| 155 | + ``` |
| 156 | + |
| 157 | +### DevTools Not Loading |
| 158 | + |
| 159 | +1. Verify the container is running: |
| 160 | + ```bash |
| 161 | + docker ps |
| 162 | + ``` |
| 163 | + |
| 164 | +2. Check Nginx is serving files: |
| 165 | + ```bash |
| 166 | + curl http://localhost:8000/ |
| 167 | + ``` |
| 168 | + |
| 169 | +3. Ensure Chrome is launched with the correct flag |
| 170 | + |
| 171 | +## Performance |
| 172 | + |
| 173 | +- **Build time**: ~10-20 minutes (first build, depending on system) |
| 174 | +- **Image size**: ~50MB (production image with Nginx) |
| 175 | +- **Memory usage**: ~50-100MB at runtime |
| 176 | +- **Startup time**: <5 seconds |
| 177 | + |
| 178 | +## Security Notes |
| 179 | + |
| 180 | +- The Nginx configuration includes security headers |
| 181 | +- CORS is enabled for DevTools functionality |
| 182 | +- The container runs as non-root user (nginx) |
| 183 | +- No sensitive data is included in the final image |
| 184 | + |
| 185 | +## Contributing |
| 186 | + |
| 187 | +When modifying the Docker setup: |
| 188 | +1. Test builds locally before committing |
| 189 | +2. Update this README if configuration changes |
| 190 | +3. Keep the final image size minimal |
| 191 | +4. Follow Docker best practices for multi-stage builds |
| 192 | + |
| 193 | +## License |
| 194 | + |
| 195 | +Same as the Chrome DevTools Frontend project - BSD-3-Clause |
0 commit comments