Skip to content

Gate Docker Deployment

This directory contains Docker configuration for the Gate (by Surkyl) API Gateway.

Terminal window
# From apps/gate directory
docker-compose up -d
# Or from repository root
docker-compose -f apps/gate/docker-compose.yml up -d

The gateway will be available at http://localhost:8080

Terminal window
# Build from repository root
docker build -f apps/gate/Dockerfile -t gate:latest .
# Run the container
docker run -d \
--name gate \
-p 8080:80 \
gate:latest

Standard Build (No Version in Server Header)

Section titled “Standard Build (No Version in Server Header)”
Terminal window
docker build -f apps/gate/Dockerfile -t gate:latest .

Server Header: Server: Gate (by Surkyl)

Terminal window
docker build \
--build-arg GATE_FEATURES="version-header" \
-f apps/gate/Dockerfile \
-t gate:versioned .

Server Header: Server: Gate (by Surkyl)/0.1.0

Terminal window
docker buildx build \
--platform linux/amd64,linux/arm64 \
-f apps/gate/Dockerfile \
-t gate:latest \
--push \
.
Terminal window
docker run -d \
--name gate \
-p 8080:80 \
gate:latest
Terminal window
docker run -d \
--name gate \
-p 8080:80 \
-e RUST_LOG=gate=debug,hypers=debug,tower_http=debug \
-e RUST_BACKTRACE=full \
gate:latest
Terminal window
docker run -d \
--name gate \
-p 80:80 \
--cap-add=NET_BIND_SERVICE \
gate:latest

The container includes a built-in health check that queries the /_health endpoint:

Terminal window
# Check container health
docker ps
# View health check logs
docker inspect gate | jq '.[0].State.Health'
VariableDefaultDescription
RUST_LOGgate=info,hypers=info,tower_http=infoLogging configuration
RUST_BACKTRACE1Enable backtraces (0=off, 1=on, full=verbose)
EndpointDescription
/_healthHealth check endpoint (global route)
/*All other routes return custom 404 page
version: '3.8'
services:
gate:
build:
context: ../..
dockerfile: apps/gate/Dockerfile
args:
GATE_FEATURES: ''
ports:
- '8080:80'
environment:
- RUST_LOG=gate=debug,hypers=debug,tower_http=debug
- RUST_BACKTRACE=full
version: '3.8'
services:
gate:
image: gate:latest
container_name: gate-prod
ports:
- '80:80'
environment:
- RUST_LOG=gate=warn,hypers=warn,tower_http=warn
- RUST_BACKTRACE=0
restart: always
cap_add:
- NET_BIND_SERVICE
  1. Planner - Generates cargo-chef recipe for dependency caching
  2. Builder - Builds dependencies and application binary
  3. Runtime - Minimal Debian-based runtime image
ImageApproximate Size
Builder Stage~2.5 GB
Final Runtime~80-120 MB
Compressed~40-60 MB
  • ✅ Non-root user (gate:gate)
  • ✅ Minimal runtime dependencies
  • ✅ CA certificates included for HTTPS
  • ✅ Health check endpoint
  • ✅ No build tools in final image
Terminal window
# Using curl
curl http://localhost:8080/_health
# Using docker exec
docker exec gate curl -f http://localhost:80/_health
Terminal window
# Follow logs
docker logs -f gate
# Last 100 lines
docker logs --tail 100 gate
Terminal window
curl -I http://localhost:8080/_health | grep Server

Expected output:

  • Without version-header: Server: Gate (by Surkyl)
  • With version-header: Server: Gate (by Surkyl)/0.1.0

If you get permission errors binding to port 80:

  1. Use port mapping to a higher port: -p 8080:80
  2. Grant NET_BIND_SERVICE capability: --cap-add=NET_BIND_SERVICE
  3. Run as root (not recommended): --user root

If cargo-chef build fails, try building without cache:

Terminal window
docker build --no-cache -f apps/gate/Dockerfile -t gate:latest .

Check logs for errors:

Terminal window
docker logs gate

Common issues:

  • Port already in use (change -p mapping)
  • Insufficient memory (increase Docker memory limit)
Terminal window
# Stop and remove container
docker-compose down
# Or with Docker CLI
docker stop gate
docker rm gate
# Remove image
docker rmi gate:latest
# Clean up build cache
docker builder prune
build-gate:
stage: build
image: docker:24
services:
- docker:24-dind
script:
- docker build -f apps/gate/Dockerfile -t $CI_REGISTRY_IMAGE/gate:$CI_COMMIT_SHA .
- docker push $CI_REGISTRY_IMAGE/gate:$CI_COMMIT_SHA
- name: Build Docker Image
run: |
docker build -f apps/gate/Dockerfile -t gate:${{ github.sha }} .
docker tag gate:${{ github.sha }} gate:latest