#!/bin/bash # This script pulls the latest image and deploys the application # Load environment variables from .env file if it exists if [ -f .env ]; then export $(cat .env | grep -v '^#' | xargs) fi # Check if required environment variables are set if [ -z "$GITEA_REGISTRY_URL" ] || [ -z "$GITEA_USERNAME" ] || [ -z "$GITEA_PASSWORD" ]; then echo "Error: Missing required environment variables. Please check your .env file." echo "Required variables: GITEA_REGISTRY_URL, GITEA_USERNAME, GITEA_PASSWORD" exit 1 fi # Login to Gitea registry echo "Logging in to Gitea registry..." echo $GITEA_PASSWORD | docker login ${GITEA_REGISTRY_URL} -u ${GITEA_USERNAME} --password-stdin if [ $? -ne 0 ]; then echo "Error: Failed to login to Gitea registry. Please check your credentials." exit 1 fi # Pull the latest image echo "Pulling the latest image..." docker pull ${GITEA_REGISTRY_URL}/quant/make-quant-py:latest if [ $? -ne 0 ]; then echo "Error: Failed to pull the latest image." exit 1 fi # Deploy with docker-compose echo "Deploying the application..." docker-compose down docker-compose up -d if [ $? -ne 0 ]; then echo "Error: Failed to deploy the application." exit 1 fi echo "Deployment completed successfully!"