Files
gymflow/deployment_guide.md
2025-12-18 07:29:35 +02:00

2.6 KiB

GymFlow Deployment Guide (NAS / Existing Container)

This guide explains how to deploy GymFlow to your Ugreen NAS by integrating it into your existing nodejs-apps container.

1. Preparation (Build)

You need to build the application on your local machine before transferring it to the NAS.

Build Frontend

Run the following in the project root:

npm install
npm run build

This creates a dist folder with the compiled frontend.

Build Backend

Run the following in the project root:

cd server
npm install
npm run build
cd ..

This creates a server/dist folder with the compiled backend.

2. Transfer Files

Copy the entire gymflow folder to your NAS. Destination: nodejs_data/gymflow (inside the folder mounted to /usr/src/app).

Ensure the following files/folders are present on the NAS:

  • gymflow/dist/ (Frontend assets)
  • gymflow/server/dist/ (Backend code)
  • gymflow/server/package.json
  • gymflow/server/prisma/ (Schema for database)
  • gymflow/ecosystem.config.cjs (PM2 config)

Note: You do not need to copy node_modules. We will install production dependencies on the NAS to ensure compatibility.

3. Integration

Update your docker-compose.yml to include GymFlow in the startup command and map the new port.

Update command

Add the following to your existing command string (append before the final pm2 logs):

... && cd ../gymflow/server && npm install --omit=dev && DATABASE_URL=file:./prod.db npx prisma db push && cd .. && pm2 start ecosystem.config.cjs && ...

Note: We assume gymflow is a sibling of ag-beats etc.

Full Command Example:

command: /bin/sh -c "npm install -g pm2 && cd ag-beats && npm install && cd ../ball-shooting && npm install && cd ../gymflow/server && npm install --omit=dev && DATABASE_URL=file:./prod.db npx prisma db push && cd .. && pm2 start ecosystem.config.cjs && cd ../ag-beats && pm2 start ecosystem.config.js && cd ../ball-shooting && pm2 start npm --name ag-ball -- start && pm2 logs --raw"

Update ports

Add the GymFlow port (3003 inside container, mapped to your choice, e.g., 3033):

ports:
 - "3030:3000"
 - "3031:3001"
 - "3032:3002"
 - "3033:3003" # GymFlow

4. Environment Variables

GymFlow uses dotenv but in this setup PM2 handles the variables via ecosystem.config.cjs.

  • Port: 3003 (Internal)
  • Database: server/prod.db (SQLite)
  • Node Env: production

5. Nginx Proxy Manager

Point your domain (e.g., gym.yourdomain.com) to the NAS IP and the mapped port (3033).

  • Scheme: http
  • Forward Hostname / IP: [NAS_IP]
  • Forward Port: 3033
  • Websockets Support: Enable (if needed for future features).