Docker
Since Hyperterse is a standalone binary, you can run it in a Docker container. There are no external dependencies required.
Dockerfile
Section titled “Dockerfile”-
Export bundle
Terminal window hyperterse export -f my-query-gateway.terse -o dist -
Create
dockerfileDockerfile FROM alpine:3.19# Install bash and ca-certificates for HTTPS database connectionsRUN apk --no-cache add bash ca-certificatesWORKDIR /app# Copy exported bundleCOPY dist/my-query-gateway /app/my-query-gateway# Make script executableRUN chmod +x /app/my-query-gatewayEXPOSE 8080CMD ["/app/my-query-gateway"] -
Build image
Terminal window docker build -t my-query-gateway-app . -
Run container
Terminal window docker run -d \-p 8080:8080 \-e DATABASE_URL="postgresql://user:pass@host:5432/db" \--name hyperterse \my-query-gateway-app
Docker Compose
Section titled “Docker Compose”-
Create
docker-compose.ymldocker-compose.yml version: '3.8'services:my-query-gateway:build: .ports: - '8080:8080'environment: - DATABASE_URL=postgresql://user:pass@localhost:5432/appdepends_on: - postgresrestart: unless-stopped# For local development with databasepostgres:image: postgres:16environment: - POSTGRES_USER=user - POSTGRES_PASSWORD=pass - POSTGRES_DB=appvolumes: - postgres_data:/var/lib/postgresql/dataports: - '5432:5432'volumes:postgres_data: -
Start services
Terminal window docker-compose up -d
Environment variables
Section titled “Environment variables”Pass credentials via environment:
docker run -d \ -p 8080:8080 \ -e DATABASE_URL="${DATABASE_URL}" \ -e REDIS_URL="${REDIS_URL}" \ my-query-gateway-appOr use .env file:
docker run -d \ -p 8080:8080 \ --env-file .env.production \ my-query-gateway-appHealth checks
Section titled “Health checks”HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ CMD wget --no-verbose --tries=1 --spider http://localhost:8080/heartbeat || exit 1Note: If using Alpine, install wget or use curl instead:
RUN apk --no-cache add bash ca-certificates wget# orHEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ CMD curl -f http://localhost:8080/heartbeat || exit 1