W
Waspโ€ข15mo ago
Artomatica

Dedicated server deployment

How to deploy wasp on bare metal (Ubuntu) server? I have a dedicated server which I use for different experiments, is there any guide on how to deploy my app not on popular providers like fly.io or netlify, but on my dedicated server?
11 Replies
MEE6
MEE6โ€ข15mo ago
Wohooo @Artomatica, you just became a Waspeteer level 3!
fossfighter
fossfighterโ€ข15mo ago
You need Docker on your machine, wasp generates docker images one for the client and one for the backend so you can host them anywhere you want. Fly or netlify are just platforms with built-in deploy support
Artomatica
ArtomaticaOPโ€ข15mo ago
Thanks, what about domain setup, things like ngnix, etc.? Should I add ngnix to wasp Docker? Sorry for stupid questions, I develop for embedded and never deployed web apps with Docker.
miho
mihoโ€ข15mo ago
I'll share a guide later, I've deployed Wasp to my server ๐Ÿ˜ƒ
Artomatica
ArtomaticaOPโ€ข15mo ago
I am experementing with docker compose, Somethimg like this services: wasp-app: image: wasp-app-image ports: - "3000:3000" nginx: image: nginx:latest volumes: - ./nginx.conf:/etc/nginx/nginx.conf ports: - "80:80" - "443:443"
miho
mihoโ€ข15mo ago
You need 1 Dockerfile for server, 1 for client ๐Ÿ˜Š
martinsos
martinsosโ€ข15mo ago
This piece of docs should be most helpful: https://wasp-lang.dev/docs/advanced/deployment/manually . As for the deatils of how to set up domain and similar -> that will be also dependant on your machine and your setup. In general, what you get generated by wasp build is: 1. static files for client. 2. dockerfile for server. So you need to deploy those somewhere, while providing them with correct ENV vars so they know how to speak to each other. You will also need a postgres DB that server will connect to, which you can also host on your own or use one of the hosting providers.
miho
mihoโ€ข15mo ago
@Artomatica I've used https://caprover.com/ to manage my server (it's a platform as a service that you put on your server and you get something like your own Heroku) I've used the following script to deploy my Wasp app there:
#!/bin/bash

set -e
set -u
set -o pipefail

SERVER_APP=myapp-server
CLIENT_APP=myapp-client
CAPROVER_URL=https://captain.apps.mydomain

IS_BUILDING=false
IS_DEPLOYING_SERVER=false
IS_DEPLOYING_CLIENT=true

if [ "$IS_BUILDING" = true ] ; then
echo "Building server..."
wasp build
fi
if [ ! -d ".wasp/build" ] ; then
echo "Error: .wasp/build doesn't exist"
exit 1
fi

cd .wasp
if [ "$IS_DEPLOYING_SERVER" = true ] ; then
echo "Tar-ing server..."
tar -czf server.tar.gz --exclude "node_modules" ./build/*
echo "Deploying server..."
caprover deploy -a $SERVER_APP -t ./server.tar.gz -u $CAPROVER_URL
rm server.tar.gz
fi

if [ "$IS_DEPLOYING_CLIENT" = true ] ; then
echo "Building client..."
cd ./build/web-app
REACT_APP_API_URL=https://$SERVER_APP.mydomain npm run build
CLIENT_DOCKERFILE=$(cat <<EOF
FROM pierrezemb/gostatic
CMD [ "-fallback", "index.html", "-enable-logging"]
COPY ./build /srv/http
EOF
)
echo "$CLIENT_DOCKERFILE" > ./Dockerfile
echo "!build" > .dockerignore

echo "Tar-ing client..."
tar -czf ../../client.tar.gz --exclude "node_modules" ./*
echo "Deploying client..."
caprover deploy -a $CLIENT_APP -t ../../client.tar.gz -u $CAPROVER_URL
rm ../../client.tar.gz
fi
#!/bin/bash

set -e
set -u
set -o pipefail

SERVER_APP=myapp-server
CLIENT_APP=myapp-client
CAPROVER_URL=https://captain.apps.mydomain

IS_BUILDING=false
IS_DEPLOYING_SERVER=false
IS_DEPLOYING_CLIENT=true

if [ "$IS_BUILDING" = true ] ; then
echo "Building server..."
wasp build
fi
if [ ! -d ".wasp/build" ] ; then
echo "Error: .wasp/build doesn't exist"
exit 1
fi

cd .wasp
if [ "$IS_DEPLOYING_SERVER" = true ] ; then
echo "Tar-ing server..."
tar -czf server.tar.gz --exclude "node_modules" ./build/*
echo "Deploying server..."
caprover deploy -a $SERVER_APP -t ./server.tar.gz -u $CAPROVER_URL
rm server.tar.gz
fi

if [ "$IS_DEPLOYING_CLIENT" = true ] ; then
echo "Building client..."
cd ./build/web-app
REACT_APP_API_URL=https://$SERVER_APP.mydomain npm run build
CLIENT_DOCKERFILE=$(cat <<EOF
FROM pierrezemb/gostatic
CMD [ "-fallback", "index.html", "-enable-logging"]
COPY ./build /srv/http
EOF
)
echo "$CLIENT_DOCKERFILE" > ./Dockerfile
echo "!build" > .dockerignore

echo "Tar-ing client..."
tar -czf ../../client.tar.gz --exclude "node_modules" ./*
echo "Deploying client..."
caprover deploy -a $CLIENT_APP -t ../../client.tar.gz -u $CAPROVER_URL
rm ../../client.tar.gz
fi
miho
mihoโ€ข15mo ago
The most interesting part is probably the fact that I add a Dockerfile for the client:
FROM pierrezemb/gostatic
CMD [ "-fallback", "index.html", "-enable-logging"]
COPY ./build /srv/http
FROM pierrezemb/gostatic
CMD [ "-fallback", "index.html", "-enable-logging"]
COPY ./build /srv/http
Artomatica
ArtomaticaOPโ€ข15mo ago
Nice, thank you, @miho. Will give it a go in the evening. I have two free Oracle instances which just sitting around doing nothing. Copcover is amazing! Thanks for the info! Paired with always free oracle cloud there is no excuses not to deploy apps anymore.
miho
mihoโ€ข15mo ago
Nice man, I'm glad you found it useful ๐Ÿ™๐Ÿผ it was always my dream to find a way to get the paid services experience on my hardware
Want results from more Discord servers?
Add your server