diff --git a/quickstart/selfhost/docker.mdx b/quickstart/selfhost/docker.mdx new file mode 100644 index 0000000..5aee4fa --- /dev/null +++ b/quickstart/selfhost/docker.mdx @@ -0,0 +1,114 @@ +--- +title: "Deploy with Docker" +description: "Deploy NextChat using Docker and Docker Compose" +--- + +## Quick Start + +Run NextChat with a single command: + +```bash +docker run -d -p 3000:3000 \ + -e OPENAI_API_KEY=sk-xxxx \ + -e CODE=your-password \ + yidadaa/chatgpt-next-web +``` + +Visit `http://localhost:3000` and use the access code you set. + +## Docker Compose + +Create a `docker-compose.yml` file: + +```yaml +version: '3' +services: + chatgpt-next-web: + image: yidadaa/chatgpt-next-web:latest + ports: + - "3000:3000" + environment: + - OPENAI_API_KEY=sk-xxxx + - CODE=your-password + - PROXY_URL=http://localhost:7890 + restart: unless-stopped +``` + +Start the service: + +```bash +docker-compose up -d +``` + +## Environment Variables + +See [Environment Variables](/quickstart/selfhost/env) for all available options. Common configurations: + +- `OPENAI_API_KEY`: Your OpenAI API key +- `CODE`: Access password (optional but recommended) +- `PROXY_URL`: HTTP proxy for API requests +- `BASE_URL`: Custom API endpoint + +## Advanced Configuration + +### Using Multiple API Keys + +```yaml +environment: + - OPENAI_API_KEY=sk-key1,sk-key2,sk-key3 +``` + +### Reverse Proxy with Nginx + +```nginx +server { + listen 80; + server_name chat.example.com; + + location / { + proxy_pass http://localhost:3000; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} +``` + +### Data Persistence + +Mount a volume to persist user settings: + +```yaml +volumes: + - ./data:/app/data +``` + +## Updating + +Pull the latest image and restart: + +```bash +docker-compose pull +docker-compose up -d +``` + +## Troubleshooting + +### Container won't start +Check logs: `docker logs ` + +### API connection issues +- Verify your API key is valid +- Check if you need a proxy in your region +- Ensure the container can reach external networks + +### High memory usage +Add memory limits: + +```yaml +deploy: + resources: + limits: + memory: 512M +```