Deploy the app i build with wasp open-saas to self hosted (VPS)
I am considering deploy the app i will be building to a VPS. Did anyone try it already that can give some tips...
11 Replies
Hi @Stefan Vitória. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Sure, deploying a Wasp app to a VPS is possible. Here are the general steps you need to follow:
1. Generating Deployable Code: Run the command
wasp build
to generate deployable code for the whole app in the .wasp/build/
directory. Note that you won't be able to build the app if you are using SQLite as a database. You'll have to switch to PostgreSQL before deploying to production [^1^].
2. Deploying the API Server (backend): There's a Dockerfile that defines an image for building the server in the .wasp/build
directory. Deploy this Docker image to your VPS and ensure the required environment variables on the server are correctly set up. The necessary environment variables include DATABASE_URL
, WASP_WEB_CLIENT_URL
, WASP_SERVER_URL
, JWT_SECRET
(if using Wasp Auth), and PORT
[^5^].
3. Deploying the Web Client (frontend): To build the web app, position yourself in .wasp/build/web-app
directory and run npm install && REACT_APP_API_URL=<url_to_wasp_backend> npm run build
. Replace <url_to_wasp_backend>
with the URL of the Wasp server that you previously deployed. The command will build the web client and put it in the build/
directory in the web-app
directory. Since the app's frontend is just a bunch of static files, you can deploy it to any static hosting provider [^3^].
4. Deploying the Database: Any PostgreSQL database will do, as long as you provide the server with the correct DATABASE_URL
env var and ensure that the database is accessible from the server [^4^].
If you are considering deploying Wasp to bare metal and/or with Docker
container + docker-compose.yml
, there is an open issue on GitHub discussing this topic. The issue includes a deploy script for Caprover (self-hosted PaaS) and a suggestion for writing a docker-compose.yml
to run a built Wasp app [^2^].
Remember, you can deploy each part of a Wasp app anywhere where you can usually deploy Node.js apps or static apps [^6^].
[^1^]: (source)[https://wasp-lang.dev/docs/advanced/deployment/manually#deploying-a-wasp-app]
[^2^]: (source)[https://github.com/wasp-lang/wasp/issues/1481]
[^3^]: (source)[https://wasp-lang.dev/docs/advanced/deployment/manually#3-deploying-the-web-client-frontend]
[^4^]: (source)[https://wasp-lang.dev/docs/advanced/deployment/manually#4-deploying-the-database]
[^5^]: (source)[https://wasp-lang.dev/docs/advanced/deployment/manually#environment-variables]
[^6^]: (source)[https://wasp-lang.dev/docs/advanced/deployment/overview]
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Stefan Vitória, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?I'm trying to do so, but I dont see a good tutorial tool, I just use netlify and fly.io for now, I'm trying to migrate to aws
@terrence maybe we should give it try and make a step by step for others... I didn`t finished my app yet, actually just starting out with wasp. But a private server would be more cost effictive...
fly.io very cheap, they have $5credit each month, so basically free for development and testing
So I haven't deployed behind VPS, but don't see why it shouldn't be doable.
We do have instructions for manual deployment here: https://wasp-lang.dev/docs/advanced/deployment/manually .
And we are here to assist you on the way!
Indeed, tutorial on how you did it could be very interesting.
@martinsos I will give it a try
Wohooo @Stefan Vitória, you just became a Waspeteer level 1!
I was thinking of using Cloudflare Pages for frontend + Cloudflare Workers for backend + supabase for database, but still didn't find the time to do so.
@Ricardo Batista the only tricky part with Cloudlfare workers is that they are serverless, and some parts of Wasp require a proper server (e.g. Jobs)!
@Stefan Vitória
do you have an update on this?
Were you able to deploy your whole app on VPS?
Nope. I didn't looked into it yet.