diff --git a/scripts/install.sh b/scripts/install.sh index 14dee4b..fdab048 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -164,6 +164,24 @@ npm ci --legacy-peer-deps --production=false echo -e "${YELLOW}Building the application...${NC}" npm run build +# Ensure public directory is accessible in standalone build +echo -e "${YELLOW}Setting up static files...${NC}" +# In standalone mode, public should be in the root, which is already copied +# But we need to ensure .next/static is properly linked/copied +if [ -d "$INSTALL_DIR/.next/standalone" ]; then + # Copy public to standalone directory if it's not there + if [ ! -d "$INSTALL_DIR/.next/standalone/public" ]; then + cp -r "$INSTALL_DIR/public" "$INSTALL_DIR/.next/standalone/public" 2>/dev/null || true + fi + # Ensure .next/static is accessible from standalone + if [ ! -d "$INSTALL_DIR/.next/standalone/.next" ]; then + mkdir -p "$INSTALL_DIR/.next/standalone/.next" + fi + if [ ! -d "$INSTALL_DIR/.next/standalone/.next/static" ]; then + cp -r "$INSTALL_DIR/.next/static" "$INSTALL_DIR/.next/standalone/.next/static" 2>/dev/null || true + fi +fi + # Check if service user exists, create if not echo -e "${YELLOW}Checking service user...${NC}" if ! id "$SERVICE_USER" &>/dev/null; then diff --git a/systemd/kspguti-schedule.service b/systemd/kspguti-schedule.service index eb7c79b..f98bb2e 100644 --- a/systemd/kspguti-schedule.service +++ b/systemd/kspguti-schedule.service @@ -6,7 +6,7 @@ After=network.target Type=simple User=www-data Group=www-data -WorkingDirectory=/opt/kspguti-schedule +WorkingDirectory=/opt/kspguti-schedule/.next/standalone Environment=NODE_ENV=production Environment=NEXT_TELEMETRY_DISABLED=1 Environment=PORT=3000 @@ -16,11 +16,11 @@ Environment=HOSTNAME=0.0.0.0 # Environment=PARSING_FAILURE_NOTIFICATIONS_TELEGRAM_BOTAPI_TOKEN=your_token_here # Environment=PARSING_FAILURE_NOTIFICATIONS_TELEGRAM_CHAT_ID=your_chat_id_here -# Load environment variables from file (optional) -# EnvironmentFile=/opt/kspguti-schedule/.env +# Load environment variables from file +EnvironmentFile=/opt/kspguti-schedule/.env # Use standalone server from Next.js build -ExecStart=/usr/bin/node /opt/kspguti-schedule/.next/standalone/server.js +ExecStart=/usr/bin/node server.js Restart=always RestartSec=10 StandardOutput=journal