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
- In Coolify dashboard go to
Projects
page. - Click on
+ Add
button and give the project a name and description. - Open
Production
environment. - Click on
+ Add new resource
button. - Click on
Private Repository (with GitHub App)
if you git repo is private. - Select your server.
localhost
is a default server. - Select a destination. By default, select the default Standalone Docker (coolify).
- Select a Github App or create a new connection with GitHub App by pressign
+ Add GitHub App
button. - Select your repo and production branch. By default,
production
branch is selected. - For
Build Pack
selectDockerfile
. - Click on
Continue
button to navigate to Coolify project dashboard. - Because we use a monorepo, we need to change in
Build
section valueBase directory
to/apps/web
and then pressSave
button. - My recommendation to disable
Auto Deploy
feature inAdvanced
section not to deploy on each push.
Adding env
variables to Coolify
- In Coolify dashboard go to
Environment Variables
page. - Click on
Develop view
button. - Copy all the variables from your
.env.production.local
file to Coolify in production box. - Press
Save
button. - Copy all the variables from your
.env.development.local
file to Coolify inPreview Environment Variables
box. - Press
Save
button.
Deploying your application
- In Coolify dashboard press
Deploy
button in the top right corner. - After successful deployment, you will see a green button with a
Running
status. - Click
Links
button and open the website URL that Coolify generated for your application by default.
Connecting your server to domain name with Cloudflare
- Register a new domain name in Cloudflare.
- Go
DNS
settings in Cloudflare Dashboard - Click
+ Add record
button. - Add
A
record with your server IP address withName
field with*
(asterix) . - Add
A
record with your server IP address withName
field your website, for example,dofastpro.com
and proxy statusEnabled
. - Add
A
record with your server IP address withName
field your website, for example,www.dofastpro.com
and proxy statusEnabled
. - Go to
SSL/TSL
page in Cloudflare Dashboard for your domain and selectFull
option withEncrypts end-to-end, using a self signed certificate on the server
- In Coolify dashboard in your website project in
General
page inDomains
section enter your domains, for example,https://dofastpro.com
andhttps://www.dofastpro.com
(in one line domains are divided by commahttps://dofastpro.com,https://www.dofastpro.com
) and pressSave
button. - Press
Redeploy
button in Coolify dashboard to deploy your application. - Check your website in browser with your domain name.