Docs
Home
  • Overview
  • Production deployment
  • aaPanel
  • aaPanel quick reference
Using SocialMine
Admin
Social platforms
Home
  • Overview
  • Production deployment
  • aaPanel
  • aaPanel quick reference
Using SocialMine
Admin
Social platforms
  • Setup & deployment

    • Setup & deployment
    • Production deployment overview
    • Deployment on aaPanel
    • aaPanel quick reference (SocialMine)
  • Guides

    • Using SocialMine
    • Admin configuration (super-admin)
    • Social platform configuration (developer portals)

Production deployment overview

This page summarizes how to deploy SocialMine for production. For aaPanel step-by-step instructions, see Deployment on aaPanel and the aaPanel quick reference.

The canonical project README in the repository also covers prerequisites, environment variables, and troubleshooting (MySQL, CORS). This guide focuses on builds, process management, and layout options.

Single root .env (required)

SocialMine loads configuration from one .env file at the repository root (parent of server/ and client/). See Setup & deployment for variable names.

On the server, place the file at:

/path/to/SocialMine/.env

Do not rely only on server/.env unless you have customized loading—the NestJS app resolves the root .env from the compiled server output.

Set at least:

  • DATABASE_URL, JWT_SECRET, ENCRYPTION_KEY
  • VITE_* values used at client build time (VITE_API_URL, etc.)
  • Production URLs: CORS_ORIGIN, FRONTEND_URL, API_PUBLIC_URL (for OAuth and media URLs)

Build artifacts

From the repository root:

# Install dependencies
cd server && npm install && cd ..
cd client && npm install && cd ..

# Server (NestJS → server/dist)
cd server && npm run build && cd ..

# Client (Vite → client/dist)
cd client && npm run build && cd ..

For database schema on a fresh server:

cd server
npm run prisma:generate
npx dotenv-cli -e ../.env -- prisma migrate deploy

Use prisma migrate deploy in production (applies existing migrations). Use prisma migrate dev only on development machines.

Ways to run in production

Option A — PM2 with ecosystem.config.js (API only on port 3000)

The repo includes ecosystem.config.js at the project root. It runs the NestJS entry (server/dist/main.js) with cwd set to server and process name socialmine.

From the repository root:

pm2 start ecosystem.config.js
pm2 save
pm2 startup

You still need a reverse proxy (Nginx, Caddy, etc.) to:

  • Serve client/dist for the browser, and/or
  • Proxy /api to http://127.0.0.1:3000

See Deployment on aaPanel for a full Nginx example.

Option B — Unified Node server (server/index.js)

The repository includes server/index.js, an Express shell that:

  • Serves the API under /api
  • Serves client/dist for the SPA and uploads under /uploads

After building both server and client, you can run:

cd server
node index.js

Use PM2 with script: ./index.js and cwd pointing at server if you choose this mode (adjust paths to match your server). Then a single port (e.g. 3000) can be exposed behind Nginx with SSL.

Option C — Split domains (common on aaPanel)

  • Frontend: https://app.example.com → static files from client/dist
  • API: https://api.example.com → reverse proxy to Nest on port 3000

Set VITE_API_URL=https://api.example.com/api before npm run build in client, and set CORS_ORIGIN / FRONTEND_URL / API_PUBLIC_URL accordingly.

Security (from repository README)

  • Use strong JWT_SECRET and ENCRYPTION_KEY (e.g. openssl rand -base64 32)
  • Use HTTPS in production; restrict admin and API access as needed
  • Never commit .env; use secrets management on the host

Related documentation

TopicWhere
Local install & env varsSetup & deployment
aaPanel (Nginx, MySQL, PM2, SSL)Deployment on aaPanel
Commands cheat sheet (paths, PM2, DB)aaPanel quick reference
OAuth callback URLsSocial platform configuration

Repository files: README.md, README_PRODUCTION.md, ecosystem.config.js, AAPANEL_DEPLOYMENT.md, AAPANEL_QUICK_REFERENCE.md (mirrored and updated in this docs site).

Last Updated: 4/19/26, 1:11 PM
Prev
Setup & deployment
Next
Deployment on aaPanel