chore: docker compose template for homeserver deployment

This commit is contained in:
2026-04-09 01:20:03 +02:00
parent 3605bef2b0
commit 808ce287a5
3 changed files with 58 additions and 0 deletions

14
.env.compose Normal file
View File

@@ -0,0 +1,14 @@
# Copy this file and fill in your values before deploying:
# cp .env.compose .env.compose.local
#
# Then run:
# docker compose --env-file .env.compose.local up -d --build
# URL your browser (and the SSR server) uses to reach the API.
# LAN example: http://192.168.1.100:8000
# Reverse proxy: https://pocketchords.yourdomain.com/api
VITE_API_URL=http://localhost:8000
# Host ports (change if something else is already using them)
API_PORT=8000
APP_PORT=3000

View File

@@ -12,6 +12,9 @@ FROM node:20-alpine AS build-env
COPY . /app/
COPY --from=development-dependencies-env /app/node_modules /app/node_modules
WORKDIR /app
# VITE_API_URL is baked into the bundle at build time (both SSR and client use it)
ARG VITE_API_URL=http://localhost:8000
ENV VITE_API_URL=$VITE_API_URL
RUN npm run build
FROM node:20-alpine

41
docker-compose.yml Normal file
View File

@@ -0,0 +1,41 @@
# PocketChords homeserver deployment template
#
# Usage:
# cp .env.compose .env.compose.local # fill in your values
# docker compose --env-file .env.compose.local up -d --build
#
# VITE_API_URL is baked into the JS bundle at build time.
# Set it to the URL your BROWSER (and SSR server) will use to reach the API.
# On a LAN homeserver: http://192.168.x.x:8000
# Behind a reverse proxy: https://pocketchords.example.com/api
services:
api:
build:
context: .
dockerfile: Dockerfile
restart: unless-stopped
ports:
- "${API_PORT:-8000}:8000"
environment:
DATABASE_URL: sqlite:///app/data/pocket-chords.db
volumes:
- api-data:/app/data
app:
build:
context: ./app
dockerfile: Dockerfile
args:
VITE_API_URL: ${VITE_API_URL:-http://localhost:8000}
restart: unless-stopped
ports:
- "${APP_PORT:-3000}:3000"
environment:
PORT: 3000
depends_on:
- api
volumes:
api-data:
driver: local