Skip to the article

CloselinePut it online

Put it online

Publish the Closeline API, dashboard and website on your own server with Docker, or each app on a Node.js host or Vercel.

For the Full Stack package

Before you deploy

Before going live. Every seed (yarn seed, yarn seed:prod and the first Docker start) creates the sample accounts with the password printed in the guides. On a server, start without the sample data instead, or change the sample accounts' passwords or delete them, and set your own JWT_SECRET before anyone else can reach the apps.

  • Run the API with NODE_ENV=production, your own JWT_SECRET and CORS_ORIGIN set to the website's and the dashboard's addresses. A production API refuses to start without them and says why.
  • Set FRONTEND_URL and DASHBOARD_URL to the dashboard's address, PUBLIC_API_URL to the API's, and PUBLIC_MEDIA_URL to the API's address followed by /media: invitation and reset links, the checkout's return pages and invoice downloads are written from them.
  • Behind a reverse proxy (Nginx, Caddy, a load balancer), set TRUST_PROXY=1, or 2 with Cloudflare in front of that proxy, so the sign-in limit counts visitors rather than the proxy.
  • Point your host's health check at GET /api/health: it answers 503 until the database holds its tables.
  • Leave DEMO_MODE and NEXT_PUBLIC_DEMO_MODE at false.

Before you deploy

Built without an API address, your app runs on its built-in sample data. On the dashboard any password signs in, the sample accounts are in the app's own code, and every change stays in the visitor's browser. Build it with your API's address before real users reach it.

The sample data mode

Leave NEXT_PUBLIC_DEMO_MODE at false.

All three apps on one server with Docker

The docker-compose.yml that runs the CRM locally also runs it on a server. Give each app its own domain behind a web server that adds HTTPS, such as Caddy or Nginx, forwarding the website's domain to port 3030, the dashboard's to 3031 and the API's to 8000.

  1. Name the three addresses and the first account

    Create .env in the closeline-full-stack folder, beside docker-compose.yml. The frontends compile the addresses into their JavaScript, and the API's CORS_ORIGIN, FRONTEND_URL, DASHBOARD_URL, PUBLIC_API_URL and PUBLIC_MEDIA_URL are built from them. SEED_SAMPLE_DATA=false starts the new volume without the sample data, with your own first account and an empty workspace of its own.

    closeline-full-stack/.env
    SITE_URL=https://www.your-domain.com
    ADMIN_URL=https://app.your-domain.com
    API_URL=https://api.your-domain.com
    SEED_SAMPLE_DATA=false
    ADMIN_EMAIL=you@your-domain.com
    ADMIN_PASSWORD=choose-a-long-password
    ADMIN_NAME=Your Name
    ADMIN_WORKSPACE=Your Company
  2. Add your keys

    The API also reads back-end/.env when it exists, for Stripe, mail, the bucket, the assistant's provider keys and the MCP key. Create it from .env.example, fill in what you use and add TRUST_PROXY=1 behind your web server. The compose file sets the database, the port, NODE_ENV=production and the addresses itself, and the API generates a JWT_SECRET into the data volume when you give none.

    Terminalin closeline-full-stack
    cp back-end/.env.example back-end/.env
  3. Start it in the background

    Terminalin closeline-full-stack
    docker compose up --build -d

    Expected result: https://api.your-domain.com/api/health answers "status":"ok", and the dashboard's domain opens the sign-in page, where your first account signs in.

The services restart with the server. The database and the uploads live in the closeline-data volume. After you change an address or a port, run docker compose up --build -d again: the frontends have to be built with the new address. SEED_SAMPLE_DATA, ADMIN_EMAIL and ADMIN_PASSWORD are read on the first start of a new volume only.

Start without the sample data

Your own first account is created with the tables, an empty workspace of its own where it is the Admin, and the installation's Platform admin role. It needs ADMIN_EMAIL and ADMIN_PASSWORD (8 to 128 characters); ADMIN_NAME (Workspace Admin when empty) and ADMIN_WORKSPACE (named after the first name when empty) are optional. More people join through invitations, or sign up from the website.

How you run the APIFirst account
Full stack with DockerSEED_SAMPLE_DATA=false with ADMIN_EMAIL and ADMIN_PASSWORD in the .env beside docker-compose.yml, before the first start
API container-e SEED_SAMPLE_DATA=false -e ADMIN_EMAIL=... -e ADMIN_PASSWORD=... on the first docker run with a new volume
Without Dockeryarn admin:create:prod once after yarn build, which asks in the terminal for any value left empty

With SEED_SAMPLE_DATA=false and no ADMIN_EMAIL or ADMIN_PASSWORD, the container creates the tables only, and its log names the command that creates the account afterwards:

Terminalin closeline-full-stack
docker compose exec -u node api node dist/database/create-admin.js

With a single API container, the same command is docker exec -it -u node <container> node dist/database/create-admin.js. It refuses to run once the installation already has its Platform admin.

The API on its own with Docker

Any host that builds from a Dockerfile can run the API alone. The container keeps its SQLite database and the uploads in /data: mount a volume there, or the data is lost with the container. Put a web server that adds HTTPS in front of port 8000.

Terminalin closeline-backend
docker build -t closeline-api .
docker run -d --restart unless-stopped -p 8000:8000 -v closeline-api-data:/data -e SEED_SAMPLE_DATA=false -e ADMIN_EMAIL=you@your-domain.com -e ADMIN_PASSWORD=choose-a-long-password -e CORS_ORIGIN=https://www.your-domain.com,https://app.your-domain.com -e FRONTEND_URL=https://app.your-domain.com -e DASHBOARD_URL=https://app.your-domain.com -e PUBLIC_API_URL=https://api.your-domain.com -e PUBLIC_MEDIA_URL=https://api.your-domain.com/media -e TRUST_PROXY=1 closeline-api

The image already runs with NODE_ENV=production and its SQLite file in /data. Pass only the values you need, each with -e. An existing database is never changed on start: after updating the image, run docker exec -u node <container> node dist/database/schema.js once to bring its tables up to the new code.

The API on a Node.js host

Set the variables from .env.example on the host, with the production values above. The build command is yarn build and the start command yarn start:prod; yarn admin:create:prod runs once on a new database. A SQLite file needs a persistent disk; on a host without one, use MySQL.

Terminal
corepack enable
yarn install
yarn build
yarn admin:create:prod
yarn start:prod

There are no migrations, and in production the API never changes the tables by itself. After an update whose code changes them, back up the database, then run yarn build and yarn schema:prod before yarn start:prod.

Payments on a server

With a live Stripe key, point a Stripe webhook at https://<api>/api/billing/webhooks/stripe with the events checkout.session.completed, invoice.paid, invoice.payment_failed and customer.subscription.deleted, and put its signing secret in STRIPE_WEBHOOK_SECRET. Renewals and failed payments are recorded only through it.

The frontends as Docker images

Each frontend's Dockerfile builds a standalone server, run as a user without admin rights: the website on port 3030, the dashboard on 3031. The addresses the browser opens are build arguments:

The dashboard, from its folder:

Terminal
docker build -t closeline-dashboard --build-arg NEXT_PUBLIC_API_BASE_URL=https://api.your-domain.com/api --build-arg NEXT_PUBLIC_BASE_URL=https://app.your-domain.com --build-arg NEXT_PUBLIC_WEBSITE_URL=https://www.your-domain.com .
docker run -d --restart unless-stopped -p 3031:3031 closeline-dashboard

The website, from its folder:

Terminal
docker build -t closeline-website --build-arg NEXT_PUBLIC_SITE_URL=https://www.your-domain.com --build-arg NEXT_PUBLIC_API_BASE_URL=https://api.your-domain.com/api --build-arg NEXT_PUBLIC_DASHBOARD_URL=https://app.your-domain.com .
docker run -d --restart unless-stopped -p 3030:3030 closeline-website

The dashboard's live updates connect to the API's address without /api, which it works out by itself; set NEXT_PUBLIC_WEBSOCKET_BASE_URL only when they live elsewhere. The website's own server calls the API while a page renders: when the browser's address does not work from inside its container, pass -e API_INTERNAL_URL= with an address that does.

A frontend on Vercel

  1. Put the app in a private Git repository

    Push the app's folder to a private repository on GitHub, GitLab or Bitbucket. Your licence does not allow sharing the source code publicly.

  2. Import it in Vercel

    Add a new project from that repository. Vercel detects Next.js; keep the default build settings. In a Full Stack repository, set the project's root directory to dashboard or website.

  3. Add the environment variables

    Add ENABLE_EXPERIMENTAL_COREPACK with the value 1, so Vercel installs with the Yarn version package.json pins. Then the app's addresses: for the dashboard NEXT_PUBLIC_API_BASE_URL, NEXT_PUBLIC_BASE_URL and NEXT_PUBLIC_WEBSITE_URL; for the website NEXT_PUBLIC_SITE_URL, NEXT_PUBLIC_API_BASE_URL and NEXT_PUBLIC_DASHBOARD_URL.

  4. Deploy

    Start the deployment, add your domain in the project's Domains settings, and add that address to the API's CORS_ORIGIN; for the dashboard, set it as the API's FRONTEND_URL and DASHBOARD_URL too.

    Expected result: Your domain opens the app: the dashboard's sign-in page, or the website's home page.

After you change a NEXT_PUBLIC_* variable, deploy again: the running app keeps the values it was built with.

A frontend on a Node.js server

With your settings in the app's .env, install, build and start:

Terminal
corepack enable
yarn install
yarn build
yarn start

The dashboard answers on PORT from its .env, 3031 by default; the website on 3030, or yarn next start -p <port> for another. Put a web server in front for your domain and HTTPS, and keep yarn start running with a process manager or a system service.

After it is online

  • Open both apps at /en and /ar and check both languages.
  • Every dashboard page tells search engines not to index it, through an X-Robots-Tag: noindex, nofollow header set in next.config.js, because a signed-in workspace does not belong in search results. The website is indexed, with its sitemap and canonical links built from NEXT_PUBLIC_SITE_URL.
  • Replace the website's sample legal pages (privacy, terms, cookies and GDPR) with your own policies.

After it is online

Check that https://api.your-domain.com/api/health answers "status":"ok", then point your frontends at https://api.your-domain.com/api.

Stuck on a step?

Find a fix before you start over.

Troubleshooting

Cookie Preferences

We use cookies to enhance your browsing experience, analyze site traffic, and personalize content. By clicking "Accept All", you consent to our use of cookies for analytics and personalized advertising.