Skip to content

Docker: Official container image for Substrate (LocalStack-compatible drop-in) #259

Closed

Description

@scttfrdmn

Summary

Provide an official Docker image for Substrate so teams can use it as a drop-in replacement for LocalStack in environments where in-process embedding isn't practical (CI pipelines with language-heterogeneous stacks, docker-compose setups, non-Go codebases).

Use Cases

  1. Legacy CI pipelines already wired for docker-compose up localstack — swap image, keep the rest
  2. Non-Go projects that can't use substrate.StartTestServer(t) directly
  3. Shared dev environments where a single Substrate instance serves multiple services under test
  4. Integration testing in Python/TypeScript/Java codebases that use AWS SDKs

Proposed Interface

FROM golang:1.24-alpine AS builder
WORKDIR /app
COPY . .
RUN go build -o substrate-server ./cmd/substrate-server/

FROM alpine:3.19
EXPOSE 4566
CMD ["/substrate-server", "--address=0.0.0.0:4566"]

Docker Compose drop-in:

services:
  substrate:
    image: ghcr.io/scttfrdmn/substrate:latest
    ports:
      - "4566:4566"
    environment:
      - SUBSTRATE_LOG_LEVEL=error
    healthcheck:
      test: ["CMD", "wget", "-q", "-O-", "http://localhost:4566/health"]
      interval: 2s
      timeout: 5s
      retries: 10

LocalStack Compatibility

Substrate already uses port 4566 by default and the same AWS SDK endpoint override pattern. The main additions needed:

  • /_localstack/health endpoint (returns {"services": {...}, "version": "..."}) for compatibility with tools that probe this
  • Configurable initial state via env vars or mounted config file (so CI can seed VPCs, AMIs, etc. without API calls)

Trade-offs vs In-Process

StartTestServer(t) Docker image
Startup time <100ms ~5-10s
State isolation Per-test Shared (requires reset endpoint)
Go-only Yes No
CI complexity Zero Requires docker
Multi-language No Yes

Both modes should be supported. The in-process mode remains the recommended path for Go projects; Docker is for everyone else.

Reset Endpoint

For shared-container test isolation, a POST /_substrate/reset endpoint that wipes all state would be valuable — analogous to LocalStack's reset behavior.

Motivation

Prism currently uses LocalStack via PRISM_USE_LOCALSTACK=true with a docker-compose file. The Docker image would allow a low-friction migration path: swap the image reference, verify behavior, then optionally migrate Go tests to StartTestServer(t) later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions