From 2025c87a8cc69076c07d95cf68b7606c8fd83ab4 Mon Sep 17 00:00:00 2001 From: Kevin Sivic Date: Mon, 1 Dec 2025 14:03:20 -0500 Subject: [PATCH] Add docker-compose for production deployment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add docker-compose.yml with app and postgres services - Add .env.example with required environment variables - Add .env to .gitignore to prevent committing secrets 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .env.example | 14 +++++++++++++ .gitignore | 5 +++++ docker-compose.yml | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 .env.example create mode 100644 docker-compose.yml diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..f589086 --- /dev/null +++ b/.env.example @@ -0,0 +1,14 @@ +# LocalSpot Environment Configuration +# Copy this file to .env and update the values + +# Required: Generate with `mix phx.gen.secret` +SECRET_KEY_BASE= + +# Database configuration +DATABASE_URL=postgres://postgres:postgres@db:5432/localspot +POSTGRES_USER=postgres +POSTGRES_PASSWORD=postgres +POSTGRES_DB=localspot + +# Application host (your domain) +PHX_HOST=localhost diff --git a/.gitignore b/.gitignore index 652cc1a..677d52c 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,8 @@ localspot-*.tar npm-debug.log /assets/node_modules/ +# Environment files with secrets +.env +.env.local +.env.*.local + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..124ead2 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,49 @@ +# Docker Compose configuration for LocalSpot production deployment +# +# Usage: +# 1. Copy .env.example to .env and configure your settings +# 2. Run: docker compose up -d +# +# For first-time setup, run migrations: +# docker compose exec localspot /app/bin/migrate + +services: + localspot: + image: forgejo.sivic.me/kevinsivic/localspot:latest + # Or build locally: + # build: . + restart: unless-stopped + ports: + - "4000:4000" + environment: + - DATABASE_URL=${DATABASE_URL:-postgres://postgres:postgres@db:5432/localspot} + - SECRET_KEY_BASE=${SECRET_KEY_BASE} + - PHX_HOST=${PHX_HOST:-localhost} + - PORT=4000 + depends_on: + db: + condition: service_healthy + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:4000/"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + + db: + image: postgres:16-alpine + restart: unless-stopped + volumes: + - postgres_data:/var/lib/postgresql/data + environment: + - POSTGRES_USER=${POSTGRES_USER:-postgres} + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres} + - POSTGRES_DB=${POSTGRES_DB:-localspot} + healthcheck: + test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres}"] + interval: 10s + timeout: 5s + retries: 5 + +volumes: + postgres_data: