Self-Hosting
Docker Setup
Running AnswerLoops with Docker Compose.
Everything here assumes you've already cloned the repo and filled in a real .env.local — see the self-host quickstart if you haven't done that part yet. Docker Compose reads that file; it doesn't generate secrets or register OAuth apps for you.
Start
docker compose up --buildOn first run this:
- Builds the Next.js app image
- Starts Postgres with a named volume (
postgres-data) for persistence - Runs Drizzle migrations automatically
- Serves the app on
http://localhost:3000
Stop (keep data)
docker compose downNever run docker compose down -v. The -v flag deletes named volumes, which includes your Postgres data. All articles, tickets, and org settings will be lost.
Rebuild after code changes
docker compose up --buildView logs
# All services
docker compose logs -f
# App only
docker compose logs app -f
# Postgres only
docker compose logs postgres -fAccess the database
docker compose exec postgres psql -U community -d communityCommon queries:
-- List all tables
\dt
-- Check org onboarding status
SELECT id, name, onboarded_at FROM orgs;
-- Check users
SELECT id, email, provider FROM users;
-- Exit
\qNamed volumes
| Volume | Contents |
|---|---|
postgres-data | All database data |
pnpm-store | pnpm package cache (speeds up rebuilds) |
Environment variables in Docker
Docker Compose reads from your .env file automatically. Any variable set in .env is available inside the app container.
To verify a variable is loaded:
docker compose exec app printenv OPENAI_API_KEY