diff --git a/caprover_deploy.sh b/caprover_deploy.sh index 7f0a0ba8..fece1bbf 100755 --- a/caprover_deploy.sh +++ b/caprover_deploy.sh @@ -44,36 +44,36 @@ fi npm run build python server/manage.py collectstatic --no-input -# create and push new docker container -VERSION=$(git log -1 --pretty=%h) -REPO="iterativ/vbv-lernwelt-django" -LATEST="${REPO}:latest" -BUILD_TIMESTAMP=$(date '+%F_%H:%M:%S') -VERSION_TAG="${REPO}:$VERSION" -docker build --platform=linux/amd64 -f compose/django/Dockerfile -t "$REPO" -t "$LATEST" -t "$VERSION_TAG" --build-arg VERSION="$VERSION" --build-arg BUILD_TIMESTAMP="$BUILD_TIMESTAMP" --build-arg GIT_COMMIT="$(git log -1 --format=%h)" . -docker push "$VERSION_TAG" - -if [[ "$APP_NAME" == "vbv-azure" ]]; then +if [[ "$APP_NAME" == "prod-azure" ]]; then # build and push azure docker container docker build --platform linux/amd64 -f compose/django/Dockerfile -t iterativ/vbv-lernwelt-django:azure . docker image push iterativ/vbv-lernwelt-django:azure -fi - -# caprover specific deployment -APP_URL="$APP_NAME.control.iterativ.ch" - -echo "Checking if $APP_URL is available..." -if ! curl --output /dev/null --silent --head --fail "$APP_URL"; then - echo "HTTP request to $APP_URL did not return a 200 status code, so we need to create the caprover app" - python caprover_cleanup.py -a "$APP_NAME*" --automated - python caprover_create_app.py -a "$APP_NAME" -fi - -# deploy to caprover, explicitly use the version tag... so if there is a mismatch you get an error message -caprover deploy -h https://captain.control.iterativ.ch -a "$APP_NAME" -i docker.io/"$VERSION_TAG" - -if [ -n "$CI" ]; then - echo "Running within Bitbucket Pipelines" - export CAPROVER_APP_URL="$APP_URL" - echo "https://$CAPROVER_APP_URL" >/tmp/caprover_app_url.txt +else + # create and push new docker container + VERSION=$(git log -1 --pretty=%h) + REPO="iterativ/vbv-lernwelt-django" + LATEST="${REPO}:latest" + BUILD_TIMESTAMP=$(date '+%F_%H:%M:%S') + VERSION_TAG="${REPO}:$VERSION" + docker build --platform=linux/amd64 -f compose/django/Dockerfile -t "$REPO" -t "$LATEST" -t "$VERSION_TAG" --build-arg VERSION="$VERSION" --build-arg BUILD_TIMESTAMP="$BUILD_TIMESTAMP" --build-arg GIT_COMMIT="$(git log -1 --format=%h)" . + docker push "$VERSION_TAG" + + # caprover specific deployment + APP_URL="$APP_NAME.control.iterativ.ch" + + echo "Checking if $APP_URL is available..." + if ! curl --output /dev/null --silent --head --fail "$APP_URL"; then + echo "HTTP request to $APP_URL did not return a 200 status code, so we need to create the caprover app" + python caprover_cleanup.py -a "$APP_NAME*" --automated + python caprover_create_app.py -a "$APP_NAME" + fi + + # deploy to caprover, explicitly use the version tag... so if there is a mismatch you get an error message + caprover deploy -h https://captain.control.iterativ.ch -a "$APP_NAME" -i docker.io/"$VERSION_TAG" + + if [ -n "$CI" ]; then + echo "Running within Bitbucket Pipelines" + export CAPROVER_APP_URL="$APP_URL" + echo "https://$CAPROVER_APP_URL" >/tmp/caprover_app_url.txt + fi fi