Fix migration require paths after reorganization
Mirror to GitHub / mirror (push) Successful in 38s
Test and Lint / backend-test (push) Successful in 1m41s
continuous-integration/drone/push Build is passing
Test and Lint / frontend-test (push) Successful in 2m21s
Version and Release / version-bump (push) Successful in 48s
Version and Release / trigger-drone (push) Has been skipped

- Updated all core migrations to use ../../src/ instead of ../src/
- Updated legacy migrations with the same path fix
- This fixes MODULE_NOT_FOUND errors during deployment

The error occurred because migrations were moved one level deeper
into core/ and legacy/ subdirectories without updating the relative
paths to the source files.
This commit is contained in:
2025-07-25 11:09:58 +02:00
parent 9854ca2f59
commit 8a0a4436b0
14 changed files with 176 additions and 203 deletions
+1
View File
@@ -33,6 +33,7 @@ jobs:
rm -rf .drone* || true rm -rf .drone* || true
rm -rf photo-sharing-prd.md || true rm -rf photo-sharing-prd.md || true
rm -rf CLAUDE.md || true rm -rf CLAUDE.md || true
rm -rf storage/ || true
+3
View File
@@ -11,6 +11,9 @@ yarn-error.log*
.env.test.local .env.test.local
.env.production.local .env.production.local
# Docker override file
docker-compose.override.yml
# Security - Never commit credentials # Security - Never commit credentials
ADMIN_CREDENTIALS.txt ADMIN_CREDENTIALS.txt
ADMIN_PASSWORD_RESET.txt ADMIN_PASSWORD_RESET.txt
+24 -17
View File
@@ -38,6 +38,13 @@ For local development, use `docker-compose.dev.yml` which includes Mailhog for e
docker-compose -f docker-compose.dev.yml up -d docker-compose -f docker-compose.dev.yml up -d
``` ```
### Production Customization
For local production customizations, copy `docker-compose.override.yml.example` to `docker-compose.override.yml`:
```bash
cp docker-compose.override.yml.example docker-compose.override.yml
# Edit docker-compose.override.yml with your customizations
```
## 🔐 Security Requirements ## 🔐 Security Requirements
### Critical: JWT Secret Setup ### Critical: JWT Secret Setup
@@ -90,10 +97,10 @@ mkdir -p storage/events/active storage/events/archived storage/thumbnails storag
mkdir -p data logs certbot/conf certbot/www mkdir -p data logs certbot/conf certbot/www
# 6. Deploy # 6. Deploy
docker-compose -f docker-compose.prod.yml up -d docker-compose up -d
# 7. Check logs # 7. Check logs
docker-compose -f docker-compose.prod.yml logs -f docker-compose logs -f
``` ```
## 📦 Deployment Methods ## 📦 Deployment Methods
@@ -165,13 +172,13 @@ services:
chmod -R 755 storage data logs chmod -R 755 storage data logs
# Build images # Build images
docker-compose -f docker-compose.prod.yml build docker-compose build
# Start services # Start services
docker-compose -f docker-compose.prod.yml up -d docker-compose up -d
# Run database migrations # Run database migrations
docker-compose -f docker-compose.prod.yml exec backend npm run migrate docker-compose exec backend npm run migrate
# Admin credentials will be displayed and saved to ADMIN_CREDENTIALS.txt # Admin credentials will be displayed and saved to ADMIN_CREDENTIALS.txt
``` ```
@@ -523,7 +530,7 @@ When you run migrations for the first time, an admin account is automatically cr
```bash ```bash
# Docker # Docker
docker-compose -f docker-compose.prod.yml exec backend npm run migrate docker-compose exec backend npm run migrate
# PM2/Manual # PM2/Manual
cd backend && npm run migrate cd backend && npm run migrate
@@ -555,7 +562,7 @@ Password: SwiftEagle3847!
```bash ```bash
# Docker # Docker
docker-compose -f docker-compose.prod.yml exec backend node scripts/reset-admin-password.js docker-compose exec backend node scripts/reset-admin-password.js
# PM2/Manual # PM2/Manual
cd backend && node scripts/reset-admin-password.js cd backend && node scripts/reset-admin-password.js
@@ -567,7 +574,7 @@ cd backend && node scripts/reset-admin-password.js
```bash ```bash
# Initial certificate # Initial certificate
docker-compose -f docker-compose.prod.yml run --rm certbot certonly \ docker-compose run --rm certbot certonly \
--webroot --webroot-path=/var/www/certbot \ --webroot --webroot-path=/var/www/certbot \
-d your-domain.com -d www.your-domain.com -d your-domain.com -d www.your-domain.com
@@ -612,7 +619,7 @@ BACKUP_DIR="./backups/$DATE"
mkdir -p $BACKUP_DIR mkdir -p $BACKUP_DIR
# Database backup # Database backup
docker-compose -f docker-compose.prod.yml exec -T db \ docker-compose exec -T db \
pg_dump -U picpeak picpeak > $BACKUP_DIR/database.sql pg_dump -U picpeak picpeak > $BACKUP_DIR/database.sql
# Files backup # Files backup
@@ -634,8 +641,8 @@ The application includes a built-in backup service. Configure via Admin Panel:
```bash ```bash
# Docker method # Docker method
git pull git pull
docker-compose -f docker-compose.prod.yml build docker-compose build
docker-compose -f docker-compose.prod.yml up -d docker-compose up -d
# PM2 method # PM2 method
git pull git pull
@@ -652,17 +659,17 @@ pm2 restart picpeak
curl https://your-domain.com/api/health curl https://your-domain.com/api/health
# Database connection # Database connection
docker-compose -f docker-compose.prod.yml exec backend \ docker-compose exec backend \
psql -U picpeak -d picpeak -c "SELECT 1" psql -U picpeak -d picpeak -c "SELECT 1"
# Service status # Service status
docker-compose -f docker-compose.prod.yml ps docker-compose ps
``` ```
#### Logs #### Logs
```bash ```bash
# Docker logs # Docker logs
docker-compose -f docker-compose.prod.yml logs -f docker-compose logs -f
# PM2 logs # PM2 logs
pm2 logs picpeak pm2 logs picpeak
@@ -720,13 +727,13 @@ chmod -R 755 storage
```bash ```bash
# Check all services # Check all services
docker-compose -f docker-compose.prod.yml ps docker-compose ps
# Backend shell access # Backend shell access
docker-compose -f docker-compose.prod.yml exec backend sh docker-compose exec backend sh
# Database access # Database access
docker-compose -f docker-compose.prod.yml exec db psql -U picpeak docker-compose exec db psql -U picpeak
# Test API # Test API
curl -I http://localhost:3001/api/health curl -I http://localhost:3001/api/health
@@ -1,4 +1,4 @@
const { db } = require('../src/database/db'); const { db } = require('../../src/database/db');
async function up() { async function up() {
console.log('Adding backup service tables and settings...'); console.log('Adding backup service tables and settings...');
@@ -1,4 +1,4 @@
const { db } = require('../src/database/db'); const { db } = require('../../src/database/db');
async function up() { async function up() {
console.log('Adding database backup tables and settings...'); console.log('Adding database backup tables and settings...');
@@ -1,5 +1,5 @@
const { db } = require('../src/database/db'); const { db } = require('../../src/database/db');
const logger = require('../src/utils/logger'); const logger = require('../../src/utils/logger');
async function up() { async function up() {
console.log('Adding backup manifest columns...'); console.log('Adding backup manifest columns...');
@@ -1,4 +1,4 @@
const { db } = require('../src/database/db'); const { db } = require('../../src/database/db');
async function up() { async function up() {
console.log('Adding version tracking to backup tables...'); console.log('Adding version tracking to backup tables...');
@@ -1,4 +1,4 @@
const { db } = require('../src/database/db'); const { db } = require('../../src/database/db');
async function up() { async function up() {
console.log('Enhancing backup system...'); console.log('Enhancing backup system...');
+2 -2
View File
@@ -1,6 +1,6 @@
const bcrypt = require('bcrypt'); const bcrypt = require('bcrypt');
const { db, initializeDatabase } = require('../src/database/db'); const { db, initializeDatabase } = require('../../src/database/db');
const { generateReadablePassword } = require('../src/utils/passwordGenerator'); const { generateReadablePassword } = require('../../src/utils/passwordGenerator');
const fs = require('fs').promises; const fs = require('fs').promises;
const path = require('path'); const path = require('path');
@@ -1,4 +1,4 @@
const { db } = require('../src/database/db'); const { db } = require('../../src/database/db');
async function up() { async function up() {
console.log('Adding photo categories and CMS tables...'); console.log('Adding photo categories and CMS tables...');
@@ -1,4 +1,4 @@
const { db } = require('../src/database/db'); const { db } = require('../../src/database/db');
async function up() { async function up() {
// Check if host_name column already exists // Check if host_name column already exists
+51
View File
@@ -0,0 +1,51 @@
# docker-compose.override.yml.example
#
# Copy this file to docker-compose.override.yml for local production customizations
# docker-compose.override.yml is git-ignored and will be automatically loaded by Docker Compose
#
# Example customizations:
version: '3.8'
services:
# Example: Expose backend port for debugging
# backend:
# ports:
# - "3001:3001"
# Example: Expose database port for local tools
# db:
# ports:
# - "5432:5432"
# Example: Custom nginx ports
# nginx:
# ports:
# - "8080:80"
# - "8443:443"
# Example: Enable Umami web interface
# umami:
# ports:
# - "3000:3000"
# Example: Use different storage paths
# backend:
# volumes:
# - /mnt/photos:/app/storage
# - /mnt/data:/app/data
# Example: Development-like setup with code mounting
# backend:
# volumes:
# - ./backend:/app
# - /app/node_modules
# command: npm run dev
# Example: Add Mailhog for email testing
# mailhog:
# image: mailhog/mailhog:latest
# ports:
# - "1025:1025"
# - "8025:8025"
# restart: unless-stopped
-121
View File
@@ -1,121 +0,0 @@
# docker-compose.prod.yml - Production configuration
version: '3.8'
services:
backend:
image: picpeak-backend:latest
build:
context: ./backend
dockerfile: Dockerfile
restart: unless-stopped
depends_on:
- db
environment:
- NODE_ENV=production
- PORT=3001
- JWT_SECRET=${JWT_SECRET}
- ADMIN_URL=${ADMIN_URL}
- FRONTEND_URL=${FRONTEND_URL}
- BACKEND_URL=${BACKEND_URL}
# Database
- DATABASE_CLIENT=pg
- DB_HOST=db
- DB_PORT=5432
- DB_USER=${DB_USER:-picpeak}
- DB_PASSWORD=${DB_PASSWORD}
- DB_NAME=${DB_NAME:-picpeak}
# Email
- SMTP_HOST=${SMTP_HOST}
- SMTP_PORT=${SMTP_PORT}
- SMTP_SECURE=${SMTP_SECURE}
- SMTP_USER=${SMTP_USER}
- SMTP_PASS=${SMTP_PASS}
- EMAIL_FROM=${EMAIL_FROM}
# Analytics
- UMAMI_URL=${UMAMI_URL}
- UMAMI_WEBSITE_ID=${UMAMI_WEBSITE_ID}
# Storage paths
- STORAGE_PATH=/app/storage
- EVENTS_PATH=/app/storage/events
- ARCHIVE_PATH=/app/storage/events/archived
volumes:
- ./storage:/app/storage
- ./data:/app/data
- ./logs:/app/logs
networks:
- picpeak
frontend:
image: picpeak-frontend:latest
build:
context: ./frontend
dockerfile: Dockerfile
args:
- VITE_API_URL=/api
restart: unless-stopped
depends_on:
- backend
networks:
- picpeak
nginx:
image: nginx:alpine
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/sites-enabled:/etc/nginx/sites-enabled
- ./certbot/conf:/etc/letsencrypt
- ./certbot/www:/var/www/certbot
depends_on:
- frontend
- backend
networks:
- picpeak
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
certbot:
image: certbot/certbot
restart: unless-stopped
volumes:
- ./certbot/conf:/etc/letsencrypt
- ./certbot/www:/var/www/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
db:
image: postgres:14-alpine
restart: unless-stopped
environment:
- POSTGRES_USER=${DB_USER:-picpeak}
- POSTGRES_PASSWORD=${DB_PASSWORD}
- POSTGRES_DB=${DB_NAME:-picpeak}
# Allow connections from any host with password authentication
- POSTGRES_HOST_AUTH_METHOD=scram-sha-256
- POSTGRES_INITDB_ARGS=--auth-host=scram-sha-256 --auth-local=trust
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- picpeak
# Allow connections without SSL requirement from Docker network
command: postgres -c ssl=off
umami:
image: ghcr.io/umami-software/umami:postgresql-latest
restart: unless-stopped
environment:
DATABASE_URL: postgresql://${DB_USER:-picpeak}:${DB_PASSWORD}@db:5432/umami
DATABASE_TYPE: postgresql
HASH_SALT: ${UMAMI_HASH_SALT}
depends_on:
- db
networks:
- picpeak
networks:
picpeak:
driver: bridge
volumes:
postgres_data:
+87 -55
View File
@@ -1,93 +1,125 @@
# docker-compose.yml - Production configuration
#
# For development, use: docker-compose -f docker-compose.dev.yml up -d
# For local customizations, create docker-compose.override.yml (see docker-compose.override.yml.example)
#
version: '3.8' version: '3.8'
services: services:
# PostgreSQL Database
db:
image: postgres:15-alpine
container_name: picpeak-postgres
environment:
POSTGRES_DB: ${DB_NAME:-picpeak}
POSTGRES_USER: ${DB_USER:-picpeak}
POSTGRES_PASSWORD: ${DB_PASSWORD:-picpeak}
volumes:
- postgres_data:/var/lib/postgresql/data
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-picpeak}"]
interval: 10s
timeout: 5s
retries: 5
# Backend API
backend: backend:
build: ./backend image: picpeak-backend:latest
container_name: picpeak-backend build:
context: ./backend
dockerfile: Dockerfile
restart: unless-stopped
depends_on: depends_on:
db: - db
condition: service_healthy
environment: environment:
NODE_ENV: production - NODE_ENV=production
PORT: 3001 - PORT=3001
DATABASE_CLIENT: pg - JWT_SECRET=${JWT_SECRET}
DB_HOST: db - ADMIN_URL=${ADMIN_URL}
DB_PORT: 5432 - FRONTEND_URL=${FRONTEND_URL}
DB_NAME: ${DB_NAME:-picpeak} - BACKEND_URL=${BACKEND_URL}
DB_USER: ${DB_USER:-picpeak} # Database
DB_PASSWORD: ${DB_PASSWORD:-picpeak} - DATABASE_CLIENT=pg
env_file: - DB_HOST=db
- .env - DB_PORT=5432
- DB_USER=${DB_USER:-picpeak}
- DB_PASSWORD=${DB_PASSWORD}
- DB_NAME=${DB_NAME:-picpeak}
# Email
- SMTP_HOST=${SMTP_HOST}
- SMTP_PORT=${SMTP_PORT}
- SMTP_SECURE=${SMTP_SECURE}
- SMTP_USER=${SMTP_USER}
- SMTP_PASS=${SMTP_PASS}
- EMAIL_FROM=${EMAIL_FROM}
# Analytics
- UMAMI_URL=${UMAMI_URL}
- UMAMI_WEBSITE_ID=${UMAMI_WEBSITE_ID}
# Storage paths
- STORAGE_PATH=/app/storage
- EVENTS_PATH=/app/storage/events
- ARCHIVE_PATH=/app/storage/events/archived
volumes: volumes:
- ./storage:/app/storage - ./storage:/app/storage
- ./data:/app/data - ./data:/app/data
restart: unless-stopped - ./logs:/app/logs
healthcheck: networks:
test: ["CMD", "curl", "-f", "http://localhost:3001/api/health"] - picpeak
interval: 30s
timeout: 10s
retries: 3
# Frontend
frontend: frontend:
build: image: picpeak-frontend:latest
build:
context: ./frontend context: ./frontend
dockerfile: Dockerfile
args: args:
VITE_API_URL: ${VITE_API_URL:-/api} - VITE_API_URL=/api
VITE_UMAMI_URL: ${VITE_UMAMI_URL} restart: unless-stopped
VITE_UMAMI_WEBSITE_ID: ${VITE_UMAMI_WEBSITE_ID}
container_name: picpeak-frontend
depends_on: depends_on:
- backend - backend
restart: unless-stopped networks:
- picpeak
# Nginx Reverse Proxy
nginx: nginx:
image: nginx:alpine image: nginx:alpine
container_name: picpeak-nginx restart: unless-stopped
ports: ports:
- "80:80" - "80:80"
- "443:443" - "443:443"
volumes: volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro - ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/sites-enabled:/etc/nginx/sites-enabled
- ./certbot/conf:/etc/letsencrypt - ./certbot/conf:/etc/letsencrypt
- ./certbot/www:/var/www/certbot - ./certbot/www:/var/www/certbot
depends_on: depends_on:
- frontend - frontend
- backend - backend
restart: unless-stopped networks:
- picpeak
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'" command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
# Certbot for SSL
certbot: certbot:
image: certbot/certbot image: certbot/certbot
container_name: picpeak-certbot restart: unless-stopped
volumes: volumes:
- ./certbot/conf:/etc/letsencrypt - ./certbot/conf:/etc/letsencrypt
- ./certbot/www:/var/www/certbot - ./certbot/www:/var/www/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'" entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
volumes: db:
postgres_data: image: postgres:15-alpine
restart: unless-stopped
environment:
- POSTGRES_USER=${DB_USER:-picpeak}
- POSTGRES_PASSWORD=${DB_PASSWORD}
- POSTGRES_DB=${DB_NAME:-picpeak}
# Allow connections from any host with password authentication
- POSTGRES_HOST_AUTH_METHOD=scram-sha-256
- POSTGRES_INITDB_ARGS=--auth-host=scram-sha-256 --auth-local=trust
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- picpeak
# Allow connections without SSL requirement from Docker network
command: postgres -c ssl=off
umami:
image: ghcr.io/umami-software/umami:postgresql-latest
restart: unless-stopped
environment:
DATABASE_URL: postgresql://${DB_USER:-picpeak}:${DB_PASSWORD}@db:5432/umami
DATABASE_TYPE: postgresql
HASH_SALT: ${UMAMI_HASH_SALT}
depends_on:
- db
networks:
- picpeak
networks: networks:
default: picpeak:
name: picpeak-network driver: bridge
volumes:
postgres_data: