Files
svelte-mud/DOCKER-README.md

99 lines
2.2 KiB
Markdown
Raw Normal View History

2025-04-21 14:12:36 +02:00
# Svelte MUD Docker Setup
This guide explains how to use Docker to build and run the Svelte MUD client.
## Prerequisites
- [Docker](https://docs.docker.com/get-docker/)
- [Docker Compose](https://docs.docker.com/compose/install/) (usually included with Docker Desktop)
## Quick Start
1. Navigate to the project directory:
```bash
cd path/to/svelte-mud
```
2. Build and start the containers:
```bash
docker-compose up -d
```
3. Access the application:
- Web interface: http://localhost:3000
2025-04-21 22:18:23 +02:00
- WebSocket server: ws://localhost:3000/mud-ws (both services now run on the same port)
2025-04-21 14:12:36 +02:00
## Docker Commands
### Starting the Application
```bash
# Build and start in detached mode
docker-compose up -d
# Build and start with logs
docker-compose up
# Force rebuild
docker-compose up --build
```
### Stopping the Application
```bash
# Stop containers
docker-compose down
# Stop containers and remove volumes
docker-compose down -v
```
### Viewing Logs
```bash
# View all logs
docker-compose logs
# Follow logs
docker-compose logs -f
# View logs for specific service
docker-compose logs -f svelte-mud
```
## Configuration
2025-04-21 22:18:23 +02:00
The Docker setup uses a single port for both the web interface and WebSocket server:
- Port 3000: Unified server (Web + WebSocket)
2025-04-21 14:12:36 +02:00
You can modify these ports in the `docker-compose.yml` file if needed.
## Customization
### Environment Variables
You can add environment variables in the `docker-compose.yml` file:
```yaml
services:
svelte-mud:
environment:
- NODE_ENV=production
2025-04-21 22:18:23 +02:00
- PORT=3000
2025-04-21 14:12:36 +02:00
# Add your custom environment variables here
```
### Building for Production
The default configuration is optimized for production use. It:
- Uses a multi-stage build process to minimize image size
- Runs as a non-root user for better security
- Includes only production dependencies
## Troubleshooting
2025-04-21 22:18:23 +02:00
1. **Port conflicts**: If port 3000 is already in use, modify the port mapping in `docker-compose.yml`.
2025-04-21 14:12:36 +02:00
2. **Build failures**: Ensure that all dependencies are properly defined in your package.json.
2025-04-21 22:18:23 +02:00
3. **Connection issues**: If you can't connect to the WebSocket server, verify that your client is using the correct URL format: `ws://localhost:3000/mud-ws?host=YOUR_MUD_HOST&port=YOUR_MUD_PORT`.