PySaaS
Search
K
🚗

Deployment

Easily Self Host Your Application

Self Hosting

You can use any cloud provider to host your application. In this guide, we'll show you how to deploy with DigitalOcean. If you use the hyperlink right before this sentence, you will get a free $200 credit for your account! (We will also get a small bonus if you end up spending $25 eventually on that account)
DigitalOcean Referral Badge

Create a VM

After you sign in or make an account, create an Ubuntu 20 VM (Droplet) in the region closest to your users. If you're just starting, the Regular CPU option is fine.

Environment Setup

You should now have an IP address after creating an Ubuntu VM. SSH into your VM to get set up with requirements.
ssh root@<IP>
apt-get update
apt install python3-pip nodejs zip

Clone Your Code

You can now clone your repository and install the necessary requirements. As an example, we'll clone the PySaaS boilerplate and assume you've set up your environment variables on your VM.
git clone https://github.com/getpysaas/pysaas.git
cd pysaas
pip install -r requirements.txt

Set API URL

Match the api_url parameter in rxconfig.py to your IP address:
import reflex as rx
config = rx.Config(
app_name="pysaas",
api_url="http://<IP>:8000",
db_url="sqlite:///reflex.db",
env=rx.Env.DEV,
)

Run Your App

Run a test in development mode to make sure everything works as expected.
reflex init
reflex run --port 80
To run in production mode and create an optimized build of your app, run:
reflex run --env prod --port 80
You should now be able to see the app live by typing your IP address into your browser. Now, if you'd like, get a custom domain and point it to your IP address!