fix:deploy
This commit is contained in:
@@ -17,8 +17,7 @@ const sessionSecret = process.env.SESSION_SECRET;
|
||||
if (!sessionSecret) throw new Error("SESSION_SECRET env var is required");
|
||||
|
||||
const app = Fastify({
|
||||
// In prod: warn-level only to reduce noise; in dev: full pretty logging
|
||||
logger: isProd ? { level: "warn" } : true,
|
||||
logger: isProd ? { level: "info" } : true,
|
||||
// Trust the nginx reverse proxy so secure cookies and req.ip work correctly
|
||||
trustProxy: isProd,
|
||||
});
|
||||
|
||||
@@ -80,7 +80,8 @@ export const authRouter: FastifyPluginAsync = async (fastify) => {
|
||||
|
||||
req.session.user = user;
|
||||
const base = process.env.FRONTEND_APP_URL ?? "http://localhost:5173";
|
||||
reply.redirect(`${base}?login=1`);
|
||||
const baseUrl = base.endsWith("/") ? base : `${base}/`;
|
||||
reply.redirect(`${baseUrl}?login=1`);
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
35
deploy.sh
35
deploy.sh
@@ -1,9 +1,40 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Usage: ./deploy.sh [options] [target]
|
||||
# Target: all (default), backend, frontend
|
||||
# Options: --no-pull
|
||||
|
||||
TARGET="all"
|
||||
NO_PULL=false
|
||||
|
||||
# Parse arguments
|
||||
for arg in "$@"; do
|
||||
case $arg in
|
||||
--no-pull)
|
||||
NO_PULL=true
|
||||
;;
|
||||
backend|frontend|all)
|
||||
TARGET=$arg
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $arg"
|
||||
echo "Usage: $0 [--no-pull] [all|backend|frontend]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Git pull
|
||||
if [ "$NO_PULL" = false ]; then
|
||||
echo "Pulling latest code..."
|
||||
git pull
|
||||
else
|
||||
echo "Skipping git pull..."
|
||||
fi
|
||||
|
||||
# Deploy frontend
|
||||
if [ "$TARGET" = "all" ] || [ "$TARGET" = "frontend" ]; then
|
||||
echo "Building frontend..."
|
||||
docker compose --profile build build frontend-builder
|
||||
docker compose --profile build run --rm frontend-builder
|
||||
@@ -11,9 +42,13 @@ docker compose --profile build run --rm frontend-builder
|
||||
echo "Copying frontend dist to nginx..."
|
||||
sudo mkdir -p /var/www/support-ticket-demo
|
||||
sudo cp -r frontend/dist/. /var/www/support-ticket-demo/
|
||||
fi
|
||||
|
||||
# Deploy backend
|
||||
if [ "$TARGET" = "all" ] || [ "$TARGET" = "backend" ]; then
|
||||
echo "Building and restarting backend..."
|
||||
docker compose up -d --build --remove-orphans backend
|
||||
fi
|
||||
|
||||
echo "Cleaning up old images..."
|
||||
docker image prune -f
|
||||
|
||||
Reference in New Issue
Block a user