Sunday, December 29, 2024
How to deploy a full stack SvelteKit app with Prisma and SQLite
Welcome to the SvelteKit Deployment Guide! In this step-by-step walkthrough, you'll learn how to deploy a full-stack SvelteKit app with a SQLite database and Prisma on your server.
Prerequisites
- A running Sama Deploy instance and a server set up for deployments. If you don’t have this, start by following the Quick Start Guide.
- A GitHub repository containing your SvelteKit app
Install Prisma
I assume you already have Prisma and SQLite set up for your application. If not, refer to the Prisma blog post on SvelteKit and Prisma and follow the steps outlined there.
Setup Dockerfile
Sama Deploy uses Docker to deploy your app. All you need to provide is a functional Dockerfile—that’s it! Sama Deploy handles everything else. You can use your own Dockerfile or start with the example below, which works with Prisma, SQLite, and SvelteKit. Feel free to adjust it to meet your specific needs.
Deploy your app
To deploy your application, start by opening the server where you want to deploy it.
- Click on the 'Servers' menu entry
- Click on the server of your choice
Then click on deploy now.
Next, fill out the form and click 'Create App'. You can leave the domain field as it is, because it is prefilled with the server's IP address. This is sufficient if there is only one app running on that domain. You can always update the domain later in the settings if needed.
After that, you will be redirected to the app detail view, and the deployment process will begin. The progress will be streamed in real-time on the overview page. Once the deployment is complete, the container status will display a green light with the label 'Running,' indicating that everything is set up. Your app will now be accessible at the provided domain (which is the servers IP address if you left the default).
Update the domain
Next, let’s update the app's domain. By default, it is set to the server's IP address.
To change this:
- Click on the "Settings" tab.
- Enter your desired domain in the domain field.
- Click 'Update'.
The app deployed in this guide can be found on GitHub: Sama Deploy Example SvelteKit.