Documentation

Run the API with Docker

Build the backend image, map its port, and connect the frontend.

Step 01

Build the image

Start Docker, then run this from the project root. The first build downloads the base images and Rust dependencies.

Terminal
docker build -t lightening-decoder-api .

The multi-stage build compiles Rust in the builder image and copies the API executable into a smaller runtime image.

Step 02

Start the container

Terminal
docker run --rm -p 3001:10000 \
  -e PORT=10000 \
  -e PUBLIC_BASE_URL=http://localhost:3001 \
  -e ALLOWED_ORIGINS=http://localhost:3000 \
  lightening-decoder-api

This maps port 3001 on your computer to port 10000 in the container. Use this instead of running the Cargo backend on the same port. Ctrl+C stops this foreground container.

Step 03

Connect your frontend

Set NEXT_PUBLIC_API_BASE_URL=http://localhost:3001 in frontend/.env.local and restart the frontend. Docker runs the API only; start the frontend separately using the local setup guide.

Terminal
curl http://localhost:3001/health

Step 04

Inspect build timeouts

Terminal
docker build --progress=plain -t lightening-decoder-api .

--progress=plain makes logs easier to read; it does not speed up the build. Registry download timeouts indicate connectivity problems. Check your network, VPN, or Docker proxy. Cached dependencies can be reused on the next build.

Cargo resolves the workspace, so download errors can mention terminal dependencies even when building the API.

← All guides