Skip to content

Commit

Permalink
Adding publish scripts for publishing docker containers to ECR. (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
willmeister authored Apr 13, 2020
1 parent 2c34473 commit 07d1ab8
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Docker
This directory contains necessary scripts to build and publish each of our docker containers to AWS ECR.

## Publish scripts
The `AWS_ACCOUNT_NUMBER` environment variable will need to be set in order to use these scripts. It's recommended to just add this to your profile.

The only parameter is an optional tag name. If no tag is specified, `latest` will be used.
32 changes: 32 additions & 0 deletions docker/publish-geth-container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh
# Publish Geth Container
# Optional 1st argument is tag name. Default is 'latest'.

set -e

if [ $# -eq 1 ]; then
GETH_TAG=$1
echo "Found tag '$GETH_TAG'. Using this as the container tag."
fi

BASE_DIR=$(dirname $0)
TAG=${GETH_TAG:-latest}

if [ -z "$AWS_ACCOUNT_NUMBER" ]; then
echo "No AWS_ACCOUNT_NUMBER env variable is set. Please set it to use this script."
exit 1
fi

echo "\nAuthenticating within ECR...\n"
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin "$AWS_ACCOUNT_NUMBER.dkr.ecr.us-east-2.amazonaws.com/optimism/geth"

echo "\nBuilding Geth container...\n"
docker build -t optimism/geth "$BASE_DIR/geth/."

echo "\nTagging Geth container as $TAG...\n"
docker tag optimism/geth:latest "$AWS_ACCOUNT_NUMBER.dkr.ecr.us-east-2.amazonaws.com/optimism/geth:$TAG"

echo "\nPushing Geth container to ECR...\n"
docker push "$AWS_ACCOUNT_NUMBER.dkr.ecr.us-east-2.amazonaws.com/optimism/geth:$TAG"

echo "\nPublish complete!"
37 changes: 37 additions & 0 deletions docker/publish-rollup-fullnode-container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh
# Publish Rollup Fullnode Container
# Optional 1st argument is tag name. Default is 'latest'.

set -e

if [ $# -eq 1 ]; then
FULLNODE_TAG=$1
echo "Found tag '$FULLNODE_TAG'. Using this as the container tag."
fi

SCRIPT_DIR=$(dirname $0)
ROOT_DIR=$SCRIPT_DIR/..

TAG=${FULLNODE_TAG:-latest}

if [ -z "$AWS_ACCOUNT_NUMBER" ]; then
echo "No AWS_ACCOUNT_NUMBER env variable is set. Please set it to use this script."
exit 1
fi

# Make sure we build so the container is using the current source
yarn --cwd $ROOT_DIR clean && yarn --cwd $ROOT_DIR build

echo "\nAuthenticating within ECR...\n"
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin "$AWS_ACCOUNT_NUMBER.dkr.ecr.us-east-2.amazonaws.com/optimism/rollup-full-node"

echo "\nBuilding fullnode container...\n"
docker build -t optimism/rollup-full-node "$ROOT_DIR"

echo "\nTagging fullnode container as $TAG in ECR...\n"
docker tag optimism/rollup-full-node:latest "$AWS_ACCOUNT_NUMBER.dkr.ecr.us-east-2.amazonaws.com/optimism/rollup-full-node:$TAG"

echo "\nPushing fullnode container to ECR...\n"
docker push "$AWS_ACCOUNT_NUMBER.dkr.ecr.us-east-2.amazonaws.com/optimism/rollup-full-node:$TAG"

echo "\nPublish complete!"

0 comments on commit 07d1ab8

Please sign in to comment.