Stacks / Polyglot
Preview environments for Polyglot.
When your stack doesn't fit any single template.
- Anything
- Everything
- All at once
Most real applications are polyglot by the time they hit three engineers. A Next.js frontend, a Go API, a Python worker, Postgres, a cache, an object store. Galley treats this as the default shape, not an edge case.
The config
version: 1
services:
web:
kind: web
build:
path: ./web # Next.js
expose: 3000
depends_on: [api]
env:
NEXT_PUBLIC_API_URL: "https://${GALLEY_PREVIEW_HOST_api}"
api:
kind: api
build:
path: ./api # Go
expose: 8080
depends_on: [postgres, cache, objstore]
env:
DATABASE_URL: postgres://app:pw@postgres:5432/app
REDIS_URL: redis://cache:6379/0
S3_ENDPOINT: http://objstore:9000
S3_BUCKET: myapp-uploads
S3_ACCESS_KEY: minio
S3_SECRET_KEY: minio12345
worker:
kind: worker
build:
path: ./worker # Python
start: "python -m worker"
depends_on: [postgres, cache]
env:
DATABASE_URL: postgres://app:pw@postgres:5432/app
REDIS_URL: redis://cache:6379/0
postgres:
kind: database
image: postgres:16-alpine
expose: 5432
env:
POSTGRES_USER: app
POSTGRES_PASSWORD: pw
POSTGRES_DB: app
cache:
kind: cache
image: redis:7-alpine
expose: 6379
objstore:
kind: other
image: minio/minio:latest
expose: 9000
env:
MINIO_ROOT_USER: minio
MINIO_ROOT_PASSWORD: minio12345
Multi-web-service note: when there’s both a web and an api (or two
web services), each lands at a named subdomain — web.pr-N-...,
api.pr-N-.... Use ${GALLEY_PREVIEW_HOST_<service>} in env values to
thread the right URL into the right place (here, the frontend’s
NEXT_PUBLIC_API_URL resolves to the backend’s preview host at deploy
time).
The usual gotcha
Detection is conservative for polyglot repos. With web/, api/, and
worker/ directories, Galley relies on your explicit build.path per
service rather than guessing — write the services: block fully, don’t
expect autodetect to work it out across subdirectories.
If you hit something unexpected, the galley.yml reference covers every field with constraints. Email if anything’s missing or surprising.