2023-03-11 05:35:55 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-09-10 22:20:50 +00:00
|
|
|
set -e
|
2023-03-11 05:35:55 +00:00
|
|
|
|
2023-09-10 22:20:50 +00:00
|
|
|
# Build the image locally first
|
2023-03-11 05:35:55 +00:00
|
|
|
docker build . -t reverse-proxy:latest
|
2023-09-10 22:20:50 +00:00
|
|
|
|
|
|
|
# Tag as required
|
2023-03-11 05:35:55 +00:00
|
|
|
docker tag reverse-proxy:latest 805875567437.dkr.ecr.us-west-1.amazonaws.com/reverse-proxy:latest
|
|
|
|
|
2023-09-10 22:20:50 +00:00
|
|
|
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
|
2023-03-11 05:35:55 +00:00
|
|
|
|