Simplifying build and run scripts for general & pipeline usage

This commit is contained in:
shockrah 2023-09-10 15:20:50 -07:00
parent 9cd2fe11db
commit 6b75b2534e
2 changed files with 29 additions and 11 deletions

View File

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

View File

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