Docker Compose for Go REST API

A Go HTTP server. Lightweight, fast, and simple.

go golang api backend
compose.yaml
services:
  api:
    build: .
    ports:
      - target: 8080
        mode: ingress
    environment:
      - PORT=8080
    healthcheck:
      test:
        - CMD
        - curl
        - -f
        - http://localhost:8080/
      interval: 30s
      timeout: 5s
      retries: 3
    deploy:
      resources:
        reservations:
          cpus: "0.25"
          memory: 128M
    restart: unless-stopped

Services

  • api .

Deploy

$ npx defang@latest compose up

Learn more about Defang