diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a505950 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,32 @@ +# Dependencies +node_modules + +# Build output +dist + +# Git +.git +.github + +# IDE +.idea +.vscode + +# OS +.DS_Store + +# Environment +.env +.env.* + +# Documentation +*.md +license + +# Docker +Dockerfile* +docker-compose*.yml +.dockerignore + +# Other +*.log diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..9dddc97 --- /dev/null +++ b/.env.example @@ -0,0 +1,12 @@ +# Monochrome Docker Configuration +# Copy to .env and edit: cp .env.example .env + +# --- Monochrome --- +MONOCHROME_PORT=3000 +MONOCHROME_DEV_PORT=5173 + +# --- PocketBase (only used with --profile pocketbase) --- +POCKETBASE_PORT=8090 +PB_ADMIN_EMAIL=admin@example.com +PB_ADMIN_PASSWORD=changeme +TZ=UTC diff --git a/.gitignore b/.gitignore index 3d1050b..c1ee8f9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ dist .DS_Store *.local .vite + +# Docker +.env diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..1a0e958 --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,15 @@ +# Development Dockerfile for hot-reloading +FROM oven/bun:canary-alpine + +WORKDIR /app + +# Copy package files first for caching +COPY package.json bun.lock ./ + +# Install dependencies +RUN bun install + +# Expose Vite dev server port +EXPOSE 5173 + +CMD ["bun", "run", "dev", "--", "--host", "0.0.0.0"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..57afef1 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,71 @@ +services: + # Production frontend -- always runs + monochrome: + build: + context: . + dockerfile: Dockerfile + container_name: monochrome + ports: + - "${MONOCHROME_PORT:-3000}:4173" + restart: unless-stopped + networks: + - monochrome-network + healthcheck: + test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:4173/"] + interval: 30s + timeout: 3s + retries: 3 + start_period: 5s + + # PocketBase backend -- only starts with: docker compose --profile pocketbase up -d + pocketbase: + image: ghcr.io/muchobien/pocketbase:latest + container_name: monochrome-pocketbase + profiles: + - pocketbase + restart: unless-stopped + environment: + PB_ADMIN_EMAIL: ${PB_ADMIN_EMAIL:-admin@example.com} + PB_ADMIN_PASSWORD: ${PB_ADMIN_PASSWORD:-changeme} + TZ: ${TZ:-UTC} + ports: + - "${POCKETBASE_PORT:-8090}:8090" + volumes: + - pb_data:/pb_data + - pb_public:/pb_public + - pb_hooks:/pb_hooks + command: serve --http=0.0.0.0:8090 + healthcheck: + test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8090/api/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 30s + networks: + - monochrome-network + + # Development server -- only starts with: docker compose --profile dev up -d + monochrome-dev: + build: + context: . + dockerfile: Dockerfile.dev + container_name: monochrome-dev + profiles: + - dev + ports: + - "${MONOCHROME_DEV_PORT:-5173}:5173" + volumes: + - .:/app + - /app/node_modules + command: bun run dev -- --host 0.0.0.0 + networks: + - monochrome-network + +networks: + monochrome-network: + driver: bridge + +volumes: + pb_data: + pb_public: + pb_hooks: