Skip to content

Docker

Since Hyperterse is a standalone binary, you can run it in a Docker container. There are no external dependencies required.

  1. Export bundle

    Terminal window
    hyperterse export -f my-query-gateway.terse -o dist
  2. Create dockerfile

    Dockerfile
    FROM alpine:3.19
    # Install bash and ca-certificates for HTTPS database connections
    RUN apk --no-cache add bash ca-certificates
    WORKDIR /app
    # Copy exported bundle
    COPY dist/my-query-gateway /app/my-query-gateway
    # Make script executable
    RUN chmod +x /app/my-query-gateway
    EXPOSE 8080
    CMD ["/app/my-query-gateway"]
  3. Build image

    Terminal window
    docker build -t my-query-gateway-app .
  4. 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
  1. Create docker-compose.yml

    docker-compose.yml
    version: '3.8'
    services:
    my-query-gateway:
    build: .
    ports: - '8080:8080'
    environment: - DATABASE_URL=postgresql://user:pass@localhost:5432/app
    depends_on: - postgres
    restart: unless-stopped
    # For local development with database
    postgres:
    image: postgres:16
    environment: - POSTGRES_USER=user - POSTGRES_PASSWORD=pass - POSTGRES_DB=app
    volumes: - postgres_data:/var/lib/postgresql/data
    ports: - '5432:5432'
    volumes:
    postgres_data:
  2. Start services

    Terminal window
    docker-compose up -d

Pass credentials via environment:

Terminal window
docker run -d \
-p 8080:8080 \
-e DATABASE_URL="${DATABASE_URL}" \
-e REDIS_URL="${REDIS_URL}" \
my-query-gateway-app

Or use .env file:

Terminal window
docker run -d \
-p 8080:8080 \
--env-file .env.production \
my-query-gateway-app
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/heartbeat || exit 1

Note: If using Alpine, install wget or use curl instead:

RUN apk --no-cache add bash ca-certificates wget
# or
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/heartbeat || exit 1