# Docker Support
The `Dockerfile` builds a minimal container for running mini-static with the example server that binds to all interfaces (0.0.0.0).
## Building the Image
From the workspace root:
```bash
docker build -f crates/mini-static/Dockerfile -t mini-static:latest .
```
Or use docker-compose (includes both mini-serve and mini-static):
```bash
docker-compose up
```
## Running the Container
Serve files from the crate's `public` directory on port 8080:
```bash
docker run --rm \
-p 8080:8080 \
-v ./crates/mini-static/public:/home/appuser/public:ro \
mini-static:latest
```
Environment variables:
- `PORT` — server port (default: 8080)
- `ROOT` — root directory for serving files (default: `/home/appuser/public`)
Example with custom settings:
```bash
docker run --rm \
-p 9000:9000 \
-e PORT=9000 \
-v /path/to/static:/srv/files:ro \
-e ROOT=/srv/files \
mini-static:latest
```
## Docker Compose
Start both mini-serve and mini-static:
```bash
docker-compose up
```
- **mini-serve-example** on http://localhost:8080
- **mini-static-example** on http://localhost:8081 (serves `./public`)
## API Notes
The example server uses `Server::run_all(port, timeout)` to bind to `0.0.0.0` for Docker compatibility. The library provides three binding options:
- `run(timeout)` — binds to `127.0.0.1` (loopback, ephemeral port) — safest for tests and local dev
- `run_ephemeral()` — convenience for `run()` with 30-second timeout
- `run_all(port, timeout)` — binds to `0.0.0.0` (all interfaces) — for Docker, reverse proxies, deployments
- `run_on(addr, timeout)` — full control over bind address
The default of loopback-only ensures accidental exposure is prevented; explicit `run_all()` signals network accessibility intent.
## Image Composition
- **Builder stage**: Rust 1-slim-bookworm; compiles the example server binary
- **Runtime stage**: Debian bookworm-slim; includes curl and runs as unprivileged `appuser`
The runtime container is ~80 MB (compressed) and contains only the compiled binary, with no build artifacts or source code.