Skip to content

Deploying to Production

The entire backend of Atomic CRM is hosted on Supabase. The backend is composed of a Postgres database, a REST API, and edge functions. Check out the Supabase Configuration section for details.

After configuring your Supabase instance, you can deploy the backend changes with the following command:

Terminal window
make supabase-deploy

Make sure you access the frontend once to initialize the main admin account.

If you want to test you local frontend code using the remote Supabase instance and the production settings, you can run the following command:

Terminal window
make prod-start

Note: It will apply migrations and deploy edge functions.

You can then access the app via http://localhost:3000/.

The frontend of the CRM is a Single-Page App that can be deployed to any CDN, or to GitHub Pages.

First, build the frontend bundle with:

Terminal window
make build

This will create a dist directory with the built application made of static HTML, CSS, and JS files. Upload this directory to the CDN of your choice (e.g. Netlify, Vercel, etc.).

If you want to deploy it to GitHub pages, you can use the following command:

Terminal window
npm run ghpages:deploy

The CRM will be available at https://<username>.github.io/atomic-crm/.

The built bundle contains no environment-specific setting. It reads them from a config.js file, which index.html loads before the app. This means you can build the frontend once, and deploy the same dist directory to several environments (staging, production, one instance per customer…), each with its own config.js.

make build writes a config.js from the VITE_* variables available at build time (e.g. in .env.production.local), the same way the dev server serves one from your .env files. To point a build to another environment, overwrite its config.js from environment variables (requires Node.js 22.18 or later):

Terminal window
VITE_SUPABASE_URL=https://xxxxxxxx.supabase.co \
VITE_SB_PUBLISHABLE_KEY=sb_publishable_xxxxxxxx \
node scripts/renderRuntimeConfig.ts dist/config.js

The generated file is plain JavaScript, so you can also write it by hand:

dist/config.js
window._atomicCrmConfig = {
supabaseUrl: "https://xxxxxxxx.supabase.co",
supabasePublishableKey: "sb_publishable_xxxxxxxx",
inboundEmail: "xxxxxxxx@inbound.postmarkapp.com",
};
Environment variable config.js key
VITE_SUPABASE_URL supabaseUrl
VITE_SB_PUBLISHABLE_KEY supabasePublishableKey
VITE_INBOUND_EMAIL inboundEmail
VITE_ATTACHMENTS_BUCKET attachmentsBucket
VITE_GOOGLE_WORKPLACE_DOMAIN googleWorkplaceDomain
VITE_DISABLE_EMAIL_PASSWORD_AUTHENTICATION disableEmailPasswordAuthentication
VITE_IS_DEMO isDemo

If you’ve modified the code, run the following command to deploy a new version of your CRM:

Terminal window
make prod-deploy

It will apply migrations, deploy edge functions and push the built applications to the gh-pages branch.

Automating Deployments With GitHub Actions

Section titled “Automating Deployments With GitHub Actions”

Atomic CRM contains GitHub actions for continuous integration and delivery. To enable these actions, you will have to create the following secrets on GitHub:

Terminal window
SUPABASE_ACCESS_TOKEN: Your personal access token, can be found at https://supabase.com/dashboard/account/tokens
SUPABASE_DB_PASSWORD: Your supabase database password
SUPABASE_PROJECT_ID: Your supabase project id
SUPABASE_URL: Your supabase project URL
SB_PUBLISHABLE_KEY: Your supabase project publishable key
POSTMARK_WEBHOOK_USER: User configured in Postmark to secure the webhook
POSTMARK_WEBHOOK_PASSWORD: Password configured in Postmark to secure the webhook
POSTMARK_WEBHOOK_AUTHORIZED_IPS: List of IPs (comma separated) authorized to send requests to the Postmark webhook
VITE_INBOUND_EMAIL: The email address configured in Postmark to receive inbound emails
VITE_ATTACHMENTS_BUCKET: The name of the bucket used to store attachments. Optional default to `attachments`

Note: The POSTMARK_* and VITE_INBOUND_EMAIL variables are required for Atomic CRM’s inbound email features. Have a look at the the inbound email configuration to learn more about their usage and setup.

On every push to the main branch, the check GitHub action builds the frontend once and runs the tests against that build. Once all checks pass, the deploy action updates the Supabase instance and deploys that same build to GitHub Pages, with a config.js generated from the secrets above (see Runtime Configuration).