Compare commits
3 Commits
1c5300a6f4
...
75d011f6d6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75d011f6d6 | ||
|
|
888c045f1a | ||
|
|
74b644702a |
@@ -10,40 +10,42 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Build API
|
||||
run: |
|
||||
cd api
|
||||
npm ci
|
||||
npx prisma generate
|
||||
npm run build
|
||||
|
||||
- name: Build Web
|
||||
run: |
|
||||
cd web
|
||||
npm ci
|
||||
npm run build
|
||||
|
||||
- name: Deploy API
|
||||
- name: Deploy with Docker Compose
|
||||
run: |
|
||||
pm2 stop skymoney-api || true
|
||||
rm -rf /opt/skymoney/api/dist /opt/skymoney/api/node_modules
|
||||
cp -r api/dist /opt/skymoney/api/
|
||||
cp -r api/node_modules /opt/skymoney/api/
|
||||
cp -r api/prisma /opt/skymoney/api/
|
||||
|
||||
# Run migrations using the VPS .env
|
||||
cd /opt/skymoney/api
|
||||
set -a
|
||||
source .env
|
||||
set +a
|
||||
npx prisma migrate deploy
|
||||
|
||||
pm2 start /opt/skymoney/api/dist/server.js --name skymoney-api
|
||||
# Deploy directory
|
||||
APP_DIR=/opt/skymoney
|
||||
mkdir -p $APP_DIR
|
||||
|
||||
- name: Deploy Web
|
||||
run: |
|
||||
rm -rf /var/www/skymoney/dist/*
|
||||
# Sync repo to server (excluding node_modules, dist, etc)
|
||||
rsync -a --delete \
|
||||
--exclude=node_modules \
|
||||
--exclude=dist \
|
||||
--exclude=.git \
|
||||
--exclude=.gitea \
|
||||
--exclude=backups \
|
||||
--exclude=exporting \
|
||||
./ $APP_DIR/
|
||||
|
||||
# Copy built web to shared volume
|
||||
mkdir -p /var/www/skymoney/dist
|
||||
cp -r web/dist/* /var/www/skymoney/dist/
|
||||
|
||||
cd $APP_DIR
|
||||
|
||||
# Build and start all services
|
||||
docker compose up -d --build
|
||||
|
||||
# Wait for database to be ready
|
||||
sleep 10
|
||||
|
||||
# Run Prisma migrations inside the API container
|
||||
docker compose exec -T api npx prisma migrate deploy
|
||||
|
||||
- name: Reload Nginx
|
||||
run: sudo systemctl reload nginx
|
||||
@@ -22,10 +22,10 @@ services:
|
||||
context: ./api
|
||||
dockerfile: Dockerfile
|
||||
environment:
|
||||
NODE_ENV: ${NODE_ENV:-development}
|
||||
NODE_ENV: ${NODE_ENV:-production}
|
||||
PORT: ${PORT:-8080}
|
||||
DATABASE_URL: ${DATABASE_URL:-postgres://app:app@postgres:5432/skymoney}
|
||||
CORS_ORIGIN: ${CORS_ORIGIN:-http://localhost:5173}
|
||||
CORS_ORIGIN: ${CORS_ORIGIN:-https://skymoneybudget.com}
|
||||
SEED_DEFAULT_BUDGET: ${SEED_DEFAULT_BUDGET:-0}
|
||||
AUTH_DISABLED: ${AUTH_DISABLED:-false}
|
||||
JWT_SECRET: ${JWT_SECRET:-dev-jwt-secret-change-me}
|
||||
@@ -37,29 +37,12 @@ services:
|
||||
- "8081:8080"
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
# runs *inside* the container; port 8080 is the app's internal port
|
||||
test: ["CMD-SHELL", "wget -qO- http://localhost:8080/health || exit 1"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 10s
|
||||
|
||||
caddy:
|
||||
image: caddy:2
|
||||
ports:
|
||||
- "8080:80"
|
||||
volumes:
|
||||
- ./Caddyfile.dev:/etc/caddy/Caddyfile:ro
|
||||
- ./web/dist:/srv/site:ro
|
||||
depends_on:
|
||||
- api
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "wget -qO- http://localhost/ || exit 1"]
|
||||
interval: 10s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
|
||||
scheduler:
|
||||
build:
|
||||
context: ./api
|
||||
|
||||
Reference in New Issue
Block a user