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:
- Create a Git branch “caprover” (git branch caprover)
- Do “caprover deploy” and deploy from “caprover” branch
- Remove “caprover” branch (git branch -d caprover)
- Follow usage instructions
Usage instructions:
- 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)
- Run “./deploy.bash” on the Terminal (your computer’s terminal, not inside Wappler’s Docker container) (if an error occurs, chmod +x ./deploy.bash)
- The script will ask you to switch to Production (Caprover) target, do so on Wappler
- Wappler will copy Production files from inside .wappler folder to the root directory
- Press Enter on the terminal to continue the script
- The script will create a branch “caprover”, and commit ALL changed files (refer to point 4)
- The script will call “caprover deploy --default”, which will deploy to the last selected Caprover (remember the first-time instructions?)
- Deployment success
- The script will git checkout to the branch you were at, and delete the temporary “caprover” branch used for caprover deploy
- 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:
- Automatically check which Wappler Target the user is now at
- Automatically proceed script once user changes Wappler target
Wishes for the Wappler team:
- Ability to programmatically switch between Wappler Targets
Community Page
Last updated:
Last updated: