Merge azure_deploy.sh into caprover_deploy.sh

This commit is contained in:
Daniel Egger 2023-05-30 12:04:54 +02:00
parent b967147ff5
commit df9b608d6e
1 changed files with 29 additions and 29 deletions

View File

@ -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