caprover / caprover-cli

Command Line Interface for https://github.com/caprover/caprover
72 stars 40 forks source link

Deploy not-yet-existing app #46

Closed darkspirit510 closed 4 years ago

darkspirit510 commented 4 years ago

Hey guys!

How can I deploy a new app via CLI that did not exist yet? The docs at https://caprover.com/docs/cli-commands.html describe to use -a, but this does lead to {appname} app not exist on this CapRover machine.. Do I really have to create a dummy app just to let it be overwritten?

Additional Info:

deploy command: caprover deploy

captain-definition: { "schemaVersion": 2, "dockerfilePath": "./Dockerfile" }

githubsaturn commented 4 years ago

caprover deploy doesn't "create" the app. It deploys to an already created app.

darkspirit510 commented 4 years ago

For all those searching for a solution, i wrote a script that creates a dummy application

APP_EXISTS=$(caprover api -t "/user/apps/appDefinitions/" -m GET -d "{}" | tail -n+12 | jq ".appDefinitions[] | select(.appName == \"$CAPROVER_APP\")")

if [ -z "$APP_EXISTS" ]; then
  echo "Creating new dummy app '$CAPROVER_APP' 🐣"
  caprover api -t "/user/apps/appDefinitions/register" -m POST -d "{\"appName\":\"$CAPROVER_APP\", \"hasPersistentData\": false}"
else
  echo "App '$CAPROVER_APP' already exists 🥱"
fi