Deploying a LocalStack App
Introduction
LocalStack provides a fully functional local cloud stack that emulates AWS services. Deploying LocalStack with a Dockerfile on Klutch.sh gives you reproducible builds, managed secrets, and persistent storage for stateful mocks—all controlled from klutch.sh/app. This guide covers installation, repository prep, a production-ready Dockerfile, deployment steps, Nixpacks overrides, sample usage, and production tips.
Prerequisites
- A Klutch.sh account (create one)
- A GitHub repository containing your LocalStack configuration (GitHub is the only supported git source)
- Docker familiarity
- Optional: credentials for downstream services if you proxy requests or integrate external systems
For platform onboarding, see the Quick Start.
Architecture and ports
- LocalStack serves multiple AWS-compatible endpoints; the edge gateway defaults to
4566(HTTP). Set the internal container port to4566and choose TCP traffic in Klutch.sh. - Individual service ports are auto-managed by LocalStack behind the edge port; you typically expose only
4566. - Persistent storage is recommended for
/var/lib/localstackto retain state between restarts.
Repository layout
localstack/├── Dockerfile # Must be at repo root for auto-detection├── localstack.env # Optional env overrides├── scripts/ # Helper scripts (optional)└── README.mdKeep secrets out of Git; store them in Klutch.sh environment variables.
Installation (local) and starter commands
Test LocalStack locally before pushing to GitHub:
docker run --rm -p 4566:4566 \ -e SERVICES=s3,lambda,iam \ -v $(pwd)/state:/var/lib/localstack \ localstack/localstack:latestOptional helper start.sh for portability and Nixpacks fallback:
#!/usr/bin/env bashset -euo pipefailexec localstack startMake it executable with chmod +x start.sh.
Dockerfile for LocalStack (production-ready)
Place this Dockerfile at the repo root; Klutch.sh auto-detects it (no Docker selection in the UI):
FROM localstack/localstack:1.4
WORKDIR /app
# Optional: copy additional configs or scriptsCOPY localstack.env /app/localstack.env
EXPOSE 4566CMD ["localstack", "start", "--host"]Notes:
- Pin the image tag for reproducible behavior.
- Use
localstack.envfor service lists and limits, or set env vars directly in Klutch.sh.
Environment variables (Klutch.sh)
Set these in the Klutch.sh app settings (Secrets tab) before deploying:
PORT=4566SERVICES=s3,lambda,iam(choose only the services you need)DEBUG=0(set to 1 for troubleshooting)DATA_DIR=/var/lib/localstack(persist state)LAMBDA_EXECUTOR=docker-reuse(orlocaldepending on your use case)LOCALSTACK_HOST=example-app.klutch.sh
If you deploy without the Dockerfile and need Nixpacks overrides:
NIXPACKS_BUILD_CMD="echo LocalStack uses prebuilt image"NIXPACKS_START_CMD=localstack start --hostNIXPACKS_JDK_VERSION=17
Attach persistent volumes
In Klutch.sh storage settings, add mount paths and sizes (no names required):
/var/lib/localstack— required if you want to persist state (S3 objects, etc.).
Ensure this path is writable inside the container.
Deploy LocalStack on Klutch.sh (Dockerfile workflow)
- Push your repository (with the Dockerfile at the root) to GitHub.
- Open klutch.sh/app, create a project, and add an app.
- Connect the GitHub repository; Klutch.sh automatically detects the Dockerfile.
- Choose TCP traffic for LocalStack.
- Set the internal port to
4566. - Add the environment variables above (services list, data dir, executor, and any
NIXPACKS_*overrides if you temporarily deploy without the Dockerfile). - Attach a persistent volume for
/var/lib/localstack, selecting a size that fits your stateful usage. - Deploy. Your LocalStack endpoint will be reachable at
example-app.klutch.sh:8000over TCP for clients and SDKs.
Sample usage (S3 with AWS CLI)
Point AWS CLI to LocalStack (replace host/port):
aws --endpoint-url http://example-app.klutch.sh:8000 s3 mb s3://demo-bucketaws --endpoint-url http://example-app.klutch.sh:8000 s3 lsHealth checks and production tips
- Use
/healthor a simple S3 list command for health probes. - Enforce network policies and credentials even for mock environments; store secrets in Klutch.sh.
- Pin image tags and upgrade intentionally.
- Monitor volume usage on
/var/lib/localstackand resize before it fills. - Limit
SERVICESto only what you need to reduce startup time and resource use.
LocalStack on Klutch.sh combines reproducible Docker builds with managed secrets, persistent state for mocked AWS services, and flexible TCP routing. With the Dockerfile at the repo root and port 4566 configured, you can run reliable AWS emulation without extra YAML or workflow overhead.