Small helper script for Caprover users (Linux/MacOS/WSL)

Hi,

For those of you deploying Wappler apps to Caprover, just sharing here a tiny script I made in the last hour, that may or may not be useful to you. By the way, if you’re a beginner, perhaps you’re better using Wappler’s native Docker integration.

This is useful if you use Git and have a separate Wappler Target just for Caprover. You develop while on Development target, and then you have a Caprover Target (here called “Production”) where you configure the production database credentials, debug mode off (as for production), etc…

First-usage instructions:

  1. Create a Git branch “caprover” (git branch caprover)
  2. Do “caprover deploy” and deploy from “caprover” branch
  3. Remove “caprover” branch (git branch -d caprover)
  4. Follow usage instructions

Usage instructions:

  1. While on Development target, commit ALL changes (sorry, it doesn’t work if you have an uncommited file laying around, it will error saying you have uncommitted changes. I’m sure we could work around that, but it requires further thought to ensure no file is unintentionally deleted)
  2. Run “./deploy.bash” on the Terminal (your computer’s terminal, not inside Wappler’s Docker container) (if an error occurs, chmod +x ./deploy.bash)
  3. The script will ask you to switch to Production (Caprover) target, do so on Wappler
  4. Wappler will copy Production files from inside .wappler folder to the root directory
  5. Press Enter on the terminal to continue the script
  6. The script will create a branch “caprover”, and commit ALL changed files (refer to point 4)
  7. The script will call “caprover deploy --default”, which will deploy to the last selected Caprover (remember the first-time instructions?)
  8. Deployment success
  9. The script will git checkout to the branch you were at, and delete the temporary “caprover” branch used for caprover deploy
  10. The script will ask you to switch to Development target
#!/bin/bash
set -e

branch_name="$(git symbolic-ref HEAD 2>/dev/null)" ||
branch_name="(unnamed branch)"    
branch_name=${branch_name##refs/heads/}

if [ "$branch_name" = "caprover" ]
then
    echo Current branch is caprover, aborting...
    exit 1
fi

trap 'echo Error: Please commit all git changes' ERR
git diff-index --quiet HEAD --
trap - ERR

echo Please switch Wappler target to Production now, and then press enter
read
git checkout -b caprover
git commit -a -m "Caprover"
caprover deploy --default
git checkout $branch_name
git branch -D caprover
echo Please switch Wappler target to Development now

Possible future improvements:

  1. Automatically check which Wappler Target the user is now at
  2. Automatically proceed script once user changes Wappler target

Wishes for the Wappler team:

  1. Ability to programmatically switch between Wappler Targets
Community Page
Last updated: