Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment to bare metal #1481

Open
infomiho opened this issue Oct 9, 2023 · 5 comments
Open

Deployment to bare metal #1481

infomiho opened this issue Oct 9, 2023 · 5 comments
Assignees
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@infomiho
Copy link
Contributor

infomiho commented Oct 9, 2023

We should write a piece about deploying Wasp to bare metal and/or with Docker container + docker-compose.yml

Using Caprover (self-hosted PaaS)

Deploy script
#!/bin/bash

set -e
set -u
set -o pipefail

SERVER_APP=socialpostgpt-server
CLIENT_APP=socialpostgpt-client
CAPROVER_URL=https://captain.apps.twoducks.dev

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.apps.twoducks.dev 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

docker-compose.yml

Writing a docker-compose.yml to run a built Wasp app should be pretty straightforward:

  • PostgreSQL container
  • server container (env variables set up properly)
  • client container
  • optional reverse-proxy in front (Nginx or Caddy)
@infomiho infomiho self-assigned this Oct 9, 2023
@infomiho infomiho added documentation Improvements or additions to documentation good first issue Good for newcomers labels Oct 9, 2023
@create-dan
Copy link

Hey can you assign this to me ?

@Martinsos
Copy link
Member

Hey @create-dan , sure go for it if you wish!
Maybe it would be good if you presented here your plan on how you would like to approach this?

@Martinsos
Copy link
Member

@Martinsos
Copy link
Member

Another related convo on Discord, this one about running server without Docker but directly instead: https://discord.com/channels/686873244791210014/1171112746633400462/1171112746633400462 .

@Martinsos
Copy link
Member

One more convo on Discord, also about running server without Docker: https://discord.com/channels/686873244791210014/1224779927505731605/1224779927505731605 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants