From 6b75b2534e91889b222cc669f212601c43c21f08 Mon Sep 17 00:00:00 2001 From: shockrah Date: Sun, 10 Sep 2023 15:20:50 -0700 Subject: [PATCH] Simplifying build and run scripts for general & pipeline usage --- docker/beta/build.sh | 29 ++++++++++++++++++++++++----- docker/beta/run.sh | 11 +++++------ 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/docker/beta/build.sh b/docker/beta/build.sh index c6b71f0..6fd9747 100644 --- a/docker/beta/build.sh +++ b/docker/beta/build.sh @@ -1,12 +1,31 @@ #!/bin/bash +set -e -# Build the image +# Build the image locally first docker build . -t reverse-proxy:latest + +# Tag as required docker tag reverse-proxy:latest 805875567437.dkr.ecr.us-west-1.amazonaws.com/reverse-proxy:latest -# ECR Authentication -aws ecr get-login-password --region us-west-1 | docker login --username AWS --password-stdin 805875567437.dkr.ecr.us-west-1.amazonaws.com +if [ "$1" = "dev" ]; then + ########################### + # Development build steps + ########################### + echo "Building local dev image" + echo "Skipping docker push because this is a local build" +elif [ "$1" = "prod" ]; then + ########################### + # Production build steps + ########################### + echo "Building production image" + echo "Authenticating to push to production registry" + # ECR Authentication + aws ecr get-login-password --region us-west-1 | docker login --username AWS --password-stdin 805875567437.dkr.ecr.us-west-1.amazonaws.com + # Pushing tagged image + docker push 805875567437.dkr.ecr.us-west-1.amazonaws.com/reverse-proxy:latest +else + echo "Unknown option given to build.sh" + exit 1 +fi -# Pushing tagged image -docker push 805875567437.dkr.ecr.us-west-1.amazonaws.com/reverse-proxy:latest diff --git a/docker/beta/run.sh b/docker/beta/run.sh index 2f02076..7b447e5 100644 --- a/docker/beta/run.sh +++ b/docker/beta/run.sh @@ -1,9 +1,8 @@ #!/bin/bash +set -e + +# This script is used for running the image locally for testing purposes + docker run --publish 80:80 --name gateway --rm \ - -e S3_ACCESS_KEY_ID="$(pass dev/project-athens-admin/key_id)" \ - -e S3_SECRET_KEY="$(pass dev/project-athens-admin/secret)" \ - -e S3_REGION=us-west-1 \ - -e S3_SERVER=s3-us-west-1.amazonaws.com \ - -e S3_BUCKET_NAME=shockrah-xyz-static-content \ - reverse-proxy + 805875567437.dkr.ecr.us-west-1.amazonaws.com/reverse-proxy:latest