From 39ff032bd0b2e713a8b7944381f0cc1d91f86bcf Mon Sep 17 00:00:00 2001 From: evan Date: Fri, 2 May 2025 19:24:49 -0700 Subject: [PATCH] remove upload.sh, no longer used --- upload.sh | 111 ------------------------------------------------------ 1 file changed, 111 deletions(-) delete mode 100755 upload.sh diff --git a/upload.sh b/upload.sh deleted file mode 100755 index 61182a58e..000000000 --- a/upload.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/bash - -# Script to build and upload OpenFront Docker image to ECR -# Usage: ./upload-openfront.sh [version_tag] - -# Load environment variables from .env file if it exists -if [ -f .env ]; then - echo "Loading configuration from .env file..." - export $(grep -v '^#' .env | xargs) -fi - -# Configuration with fallbacks -AWS_REGION=${AWS_REGION:-"eu-west-1"} -ECR_REPO_NAME=${ECR_REPO_NAME:-"openfront"} -AWS_ACCOUNT_ID=${AWS_ACCOUNT_ID:-$(aws sts get-caller-identity --query Account --output text)} -ECR_REPO_URI="$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$ECR_REPO_NAME" - -# Default version tag is 'latest' if not provided -VERSION_TAG=${1:-"latest"} - -echo "===== OpenFront Docker Image Upload Script =====" -echo "Repository: $ECR_REPO_URI" -echo "Version tag: $VERSION_TAG" -echo "================================================" - -# Check if Docker is installed -if ! command -v docker &> /dev/null; then - echo "Error: Docker is not installed. Please install Docker first." - exit 1 -fi - -# Check if AWS CLI is installed -if ! command -v aws &> /dev/null; then - echo "Error: AWS CLI is not installed. Please install AWS CLI first." - exit 1 -fi - -# Check if we're in the correct directory -if [ ! -f "Dockerfile" ]; then - echo "Error: Dockerfile not found in current directory." - echo "Please run this script from the directory containing your Dockerfile." - exit 1 -fi - -# Ensure the ECR repository exists -echo "Ensuring ECR repository exists..." -aws ecr describe-repositories --repository-names $ECR_REPO_NAME --region $AWS_REGION &> /dev/null -if [ $? -ne 0 ]; then - echo "Creating ECR repository $ECR_REPO_NAME..." - aws ecr create-repository --repository-name $ECR_REPO_NAME --region $AWS_REGION - if [ $? -ne 0 ]; then - echo "Error: Failed to create ECR repository." - exit 1 - fi -fi - -GIT_COMMIT=$(git rev-parse HEAD) -echo "Git commit: $GIT_COMMIT" - -# Build the Docker image -echo "Building Docker image..." -docker buildx build \ - --platform linux/amd64 \ - --build-arg GIT_COMMIT=$GIT_COMMIT \ - -t $ECR_REPO_NAME:$VERSION_TAG \ - . - - -# Authenticate to ECR -echo "Authenticating to ECR..." -aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ECR_REPO_URI -if [ $? -ne 0 ]; then - echo "Error: Failed to authenticate to ECR." - exit 1 -fi - -# Tag the image for ECR -echo "Tagging image for ECR..." -docker tag $ECR_REPO_NAME:$VERSION_TAG $ECR_REPO_URI:$VERSION_TAG -if [ $? -ne 0 ]; then - echo "Error: Failed to tag image." - exit 1 -fi - -# Push the image to ECR -echo "Pushing image to ECR..." -docker push $ECR_REPO_URI:$VERSION_TAG -if [ $? -ne 0 ]; then - echo "Error: Failed to push image to ECR." - exit 1 -fi - -# Also tag and push as 'latest' if we're using a specific version -if [ "$VERSION_TAG" != "latest" ]; then - echo "Also tagging as 'latest'..." - docker tag $ECR_REPO_NAME:$VERSION_TAG $ECR_REPO_URI:latest - docker push $ECR_REPO_URI:latest -fi - -echo "Verifying upload..." -aws ecr describe-images --repository-name $ECR_REPO_NAME --region $AWS_REGION --query "imageDetails[?contains(imageTags, '$VERSION_TAG')]" - -echo "================================================" -echo "✅ Success! Image uploaded to $ECR_REPO_URI:$VERSION_TAG" -echo "================================================" - -# Print helpful deployment instructions -echo "To deploy this image to your EC2 instance, SSH into your instance and run:" -echo "docker pull $ECR_REPO_URI:$VERSION_TAG" -echo "docker stop \$(docker ps -q --filter ancestor=$ECR_REPO_URI)" -echo "docker run -d -p 80:80 $ECR_REPO_URI:$VERSION_TAG" \ No newline at end of file