Docs
How to self-host your NextJS application

How to self-host your NextJS application

Step by step guide to self-host your DoFastPro NextJS application on your server

Creating a new project in Coolify

  1. In Coolify dashboard go to Projects page.
  2. Click on + Add button and give the project a name and description.
  3. Open Production environment.
  4. Click on + Add new resource button.
  5. Click on Private Repository (with GitHub App) if you git repo is private.
  6. Select your server. localhost is a default server.
  7. Select a destination. By default, select the default Standalone Docker (coolify).
  8. Select a Github App or create a new connection with GitHub App by pressign + Add GitHub App button.
  9. Select your repo and production branch. By default, production branch is selected.
  10. For Build Pack select Dockerfile.
  11. Click on Continue button to navigate to Coolify project dashboard.
  12. Because we use a monorepo, we need to change in Build section value Base directory to /apps/web and then press Save button.
  13. My recommendation to disable Auto Deploy feature in Advanced section not to deploy on each push.

Adding env variables to Coolify

  1. In Coolify dashboard go to Environment Variables page.
  2. Click on Develop view button.
  3. Copy all the variables from your .env.production.local file to Coolify in production box.
  4. Press Save button.
  5. Copy all the variables from your .env.development.local file to Coolify in Preview Environment Variables box.
  6. Press Save button.

Deploying your application

  1. In Coolify dashboard press Deploy button in the top right corner.
  2. After successful deployment, you will see a green button with a Running status.
  3. Click Links button and open the website URL that Coolify generated for your application by default.

Connecting your server to domain name with Cloudflare

  1. Register a new domain name in Cloudflare.
  2. Go DNS settings in Cloudflare Dashboard
  3. Click + Add record button.
  4. Add A record with your server IP address with Name field with * (asterix) .
  5. Add A record with your server IP address with Name field your website, for example, dofastpro.com and proxy status Enabled.
  6. Add A record with your server IP address with Name field your website, for example, www.dofastpro.com and proxy status Enabled.
  7. Go to SSL/TSL page in Cloudflare Dashboard for your domain and select Full option with Encrypts end-to-end, using a self signed certificate on the server
  8. In Coolify dashboard in your website project in General page in Domains section enter your domains, for example, https://dofastpro.com and https://www.dofastpro.com (in one line domains are divided by comma https://dofastpro.com,https://www.dofastpro.com) and press Save button.
  9. Press Redeploy button in Coolify dashboard to deploy your application.
  10. Check your website in browser with your domain name.