From 94fb352e7076dc4d9f76d93a4060bfdf44bcd57d Mon Sep 17 00:00:00 2001 From: Gen Schmitt Date: Thu, 19 Sep 2024 10:38:40 -0600 Subject: [PATCH] Updated to make code branch independent --- Dockerfile | 2 +- deploy/.gitignore | 1 + deploy/ecr-push.sh | 18 ++++++++++++++++++ deploy/env.sh | 17 +++++++++++++++++ ecr-push.sh | 9 --------- lib/extractor.rb | 1 + lib/extractor/extraction.rb | 3 ++- 7 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 deploy/.gitignore create mode 100755 deploy/ecr-push.sh create mode 100644 deploy/env.sh delete mode 100755 ecr-push.sh diff --git a/Dockerfile b/Dockerfile index 932da7c..6fd469e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # N.B.: this must match the Ruby version in the Gemfile, and /.ruby-version. -FROM --platform=linux/arm64 ruby:3.1.2 +FROM ruby:3.1.2 ENV RUBY_ENV=prod ENV RAILS_LOG_TO_STDOUT=true diff --git a/deploy/.gitignore b/deploy/.gitignore new file mode 100644 index 0000000..2cbe8e1 --- /dev/null +++ b/deploy/.gitignore @@ -0,0 +1 @@ +*.list \ No newline at end of file diff --git a/deploy/ecr-push.sh b/deploy/ecr-push.sh new file mode 100755 index 0000000..f530594 --- /dev/null +++ b/deploy/ecr-push.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +if [ $# -lt 1 ] +then + echo "Usage: ecr-push.sh " + exit 1 +fi + +source deploy/env.sh env-common.list +source deploy/env.sh env-$1.list + +# AWS CLI v1 +#eval $(aws ecr get-login --no-include-email --region $AWS_REGION --profile $AWS_PROFILE) +# AWS CLI v2 +aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ECR_HOST + +docker buildx build --platform linux/arm64 --push \ + -t $ECR_HOST/$IMAGE_NAME . diff --git a/deploy/env.sh b/deploy/env.sh new file mode 100644 index 0000000..f530e3a --- /dev/null +++ b/deploy/env.sh @@ -0,0 +1,17 @@ +## +# Copies Docker environment variables from one of the Docker variable files +# into shell environment variables. +# + +if [ $# -lt 1 ] +then + echo "Usage: env.sh " + exit 1 +fi + +while read p; do + if [[ $p != "#"* && $p != "" ]]; then + IFS='=' read -ra parts <<< "$p" + export "${parts[0]}"="${parts[1]}" + fi +done < deploy/$1 diff --git a/ecr-push.sh b/ecr-push.sh deleted file mode 100755 index 9ba2013..0000000 --- a/ecr-push.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -# -# Builds a Docker image and pushes it to AWS ECR. -# - -aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin 721945215539.dkr.ecr.us-east-2.amazonaws.com -docker buildx build -t databank-archive-extractor-prod . -docker tag databank-archive-extractor-prod:latest 721945215539.dkr.ecr.us-east-2.amazonaws.com/databank-archive-extractor-prod:latest -docker push 721945215539.dkr.ecr.us-east-2.amazonaws.com/databank-archive-extractor-prod:latest diff --git a/lib/extractor.rb b/lib/extractor.rb index 8392f9e..94f7176 100644 --- a/lib/extractor.rb +++ b/lib/extractor.rb @@ -14,4 +14,5 @@ def self.extract(bucket_name, object_key, binary_name, web_id, mime_type) archive_extractor = ArchiveExtractor.new(bucket_name, object_key, binary_name, web_id, mime_type, sqs, s3_client) archive_extractor.extract end + end \ No newline at end of file diff --git a/lib/extractor/extraction.rb b/lib/extractor/extraction.rb index 3007b21..054b314 100644 --- a/lib/extractor/extraction.rb +++ b/lib/extractor/extraction.rb @@ -78,6 +78,7 @@ def extract_features end end + def mime_from_path(path) file = File.open("#{path}") file_mime_response = MimeMagic.by_path(file).to_s @@ -128,7 +129,7 @@ def extract_zip @status = ExtractionStatus::ERROR @peek_type = PeekType::NONE report_problem("problem extracting zip listing for task: #{ex.message}") - + #return false raise ex end end