This guide explains how to:
- Build a production Docker image.
- Copy the image to a remote server via SSH (scp).
- Load and run the image on the server.
- Docker installed locally and on the server.
- SSH access to the server (key-based recommended).
- Dockerfile present in the project root.
From the project root:
# Build image using the provided Dockerfile
docker buildx build --platform linux/amd64 -t mtgscan:prod --load .Optionally verify:
docker images | grep mtgscan- Save the image to a tarball and compress:
docker save mtgscan:prod | gzip > mtgscan-prod.tar.gz- Copy to the server:
scp mtgscan-prod.tar.gz user@your-server:/tmp/- Load the image on the server:
ssh user@your-server "gunzip -c /tmp/mtgscan-prod.tar.gz | docker load"- Run the container on the server:
ssh user@your-server "docker run -d --name mtgscan -p 80:80 --restart unless-stopped mtgscan:prod"- Check it’s running:
ssh user@your-server "docker ps --filter name=mtgscan"# Create a remote context (one-time)
docker context create mtg-prod --docker "host=ssh://user@your-server"
# Build on the server
docker --context mtg-prod build -t mtgscan:prod .
# Run on the server
docker --context mtg-prod run -d --name mtgscan -p 80:80 --restart unless-stopped mtgscan:prod
# Verify
docker --context mtg-prod ps --filter name=mtgscan- Replace
user@your-serverwith your actual SSH user and host. - Ensure port 80 is open on the server or adjust the
-pmapping as needed. - For SPA routing, you may use a custom NGINX config if required.