Deploying Lovable Projects on Scalingo
Lovable is an AI app builder that helps you create web applications from natural language prompts. It generates frontend code based on the Vite framework.
Planning your Deployment
-
Sizing your application vastly depends on your use-case and the amount of traffic it needs to handle. We usually recommend to start with an M container, and adjust later depending on the metrics of your application.
-
If your project uses a database (e.g. Supabase), you may want to also migrate it to Scalingo. We usually advise to opt at least for a PostgreSQL® Starter or Business 512 addon for this purpose, and change for a bigger plan later if need be.
Migrating your Application
- On your workstation, clone your GitHub repository:
git clone <url_of_your_repo> - Create the application on Scalingo:
scalingo create my-app - Create a
Procfileat the root of your project with the following content:web: npx serve --single dist --listen $PORTThis instructs the platform to serve the static files from the
distdirectory on the port provided by thePORTenvironment variable. -
Scalingo installs packages from
devDependenciesduring the build phase, then prunes them before starting the application. This means that only packages listed underdependenciesare still available at runtime. For details, see the Node.js runtime dependencies documentation.In our case, this is important because the application relies on Vite at runtime. If Vite is only declared under
devDependencies, the build succeeds, but the application fails to boot once deployed because Scalingo no longer finds it.To fix this, let’s move the required packages to
dependencies:-
Open your
package.jsonfile, and move the following packages from thedevDependenciessection to thedependenciesone:@vitejs/plugin-react-swclovable-taggerautoprefixerpostcsstailwindcss
-
Update the
package-lock.jsonfile:npm install
-
- By default, Vite only responds to requests coming from hosts defined in its
server.allowedHostsoption, which defaults tolocalhost. To allow Vite to accept requests coming from your Scalingo domain, edit this option in yourvite.config.tsfile, so that it looks like this:server: { host: "::", port: Number(process.env.PORT) || 8080, allowedHosts: ["<name_of_your_app>.<region>.scalingo.io"], hmr: { overlay: false } } - Commit and push the files you just updated:
git add vite.config.ts package-lock.json package.json Procfile git commit -m "Migrate to scalingo" git push - Deploy to Scalingo:
git push scalingo
Migrating your Supabase Database to Scalingo
If your Lovable project uses Supabase, you may also want to migrate your database to Scalingo.
Dumping your Lovable Database
To download a backup from the Supabase dashboard:
- Open your Supabase project.
- Go to Database in the left sidebar.
- Navigate to the Backups section.
- Download the latest available backup file.
You can also use the Supabase CLI to create the database dump. To do so, please follow Supabase’s instructions.
Importing your Database to Scalingo
Once the backup is downloaded, import it into your Scalingo PostgreSQL database by following the Scalingo PostgreSQL documentation.
Updating your Application
If you update your project from Lovable later, the changes will be sync with your GitHub repository, make sure the following files still contain the changes described in this tutorial:
Procfilepackage.jsonpackage-lock.jsonvite.config.ts
If necessary, reapply the changes, then commit and push them:
git add vite.config.ts package-lock.json package.json Procfile
git commit -m "Update Lovable project for Scalingo"
git push
And deploy on Scalingo:
git push scalingo