Skip to content

Instantly share code, notes, and snippets.

@victorkurauchi
Forked from yefim/Dockerrun.aws.json
Created March 23, 2018 15:33
Show Gist options
  • Save victorkurauchi/01f8d76572f96f558fec714a70e726dd to your computer and use it in GitHub Desktop.
Save victorkurauchi/01f8d76572f96f558fec714a70e726dd to your computer and use it in GitHub Desktop.

Revisions

  1. @yefim yefim revised this gist Jul 16, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions deploy.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    #!/bin/bash

    # usage: ./deploy.sh staging f0478bd7c2f584b41a49405c91a439ce9d944657
    # license: public domain

    BRANCH=$1
    SHA1=$2
  2. @yefim yefim revised this gist Jul 16, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion deploy.sh
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ docker push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/$NAME:$VERSION
    # Replace the <AWS_ACCOUNT_ID> with the real ID
    sed -i='' "s/<AWS_ACCOUNT_ID>/$AWS_ACCOUNT_ID/" Dockerrun.aws.json
    # Replace the <NAME> with the real name
    sed -i='' "s/<NAME>/$NAME" Dockerrun.aws.json
    sed -i='' "s/<NAME>/$NAME/" Dockerrun.aws.json
    # Replace the <TAG> with the real version number
    sed -i='' "s/<TAG>/$VERSION/" Dockerrun.aws.json

  3. @yefim yefim revised this gist May 13, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion deploy.sh
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,7 @@ docker tag $NAME:$VERSION $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/$NAME:
    docker push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/$NAME:$VERSION

    # Replace the <AWS_ACCOUNT_ID> with the real ID
    sed -i='' "s/<AWS_ACCOUNT_ID/$AWS_ACCOUNT_ID/" Dockerrun.aws.json
    sed -i='' "s/<AWS_ACCOUNT_ID>/$AWS_ACCOUNT_ID/" Dockerrun.aws.json
    # Replace the <NAME> with the real name
    sed -i='' "s/<NAME>/$NAME" Dockerrun.aws.json
    # Replace the <TAG> with the real version number
  4. @yefim yefim revised this gist May 12, 2016. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    # Example Dockerfile
    FROM hello-world
  5. @yefim yefim revised this gist May 12, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion deploy.sh
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ AWS_ACCOUNT_ID=12345678900
    NAME=name-of-service-to-deploy
    EB_BUCKET=aws-s3-bucket-to-hold-application-versions

    VERSION=$1-$2
    VERSION=$BRANCH-$SHA1
    ZIP=$VERSION.zip

    aws configure set default.region us-east-1
  6. @yefim yefim revised this gist May 12, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion deploy.sh
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,7 @@ zip -r $ZIP Dockerrun.aws.json

    aws s3 cp $ZIP s3://$EB_BUCKET/$ZIP

    # Create a new Application Version with the zipped up Dockerrun file
    # Create a new application version with the zipped up Dockerrun file
    aws elasticbeanstalk create-application-version --application-name $NAME-application \
    --version-label $VERSION --source-bundle S3Bucket=$EB_BUCKET,S3Key=$ZIP

  7. @yefim yefim revised this gist May 12, 2016. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions deploy.sh
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,7 @@ NAME=name-of-service-to-deploy
    EB_BUCKET=aws-s3-bucket-to-hold-application-versions

    VERSION=$1-$2
    ZIP=$VERSION.zip

    aws configure set default.region us-east-1

    @@ -28,8 +29,6 @@ sed -i='' "s/<NAME>/$NAME" Dockerrun.aws.json
    # Replace the <TAG> with the real version number
    sed -i='' "s/<TAG>/$VERSION/" Dockerrun.aws.json

    ZIP=$VERSION.zip

    # Zip up the Dockerrun file (feel free to zip up an .ebextensions directory with it)
    zip -r $ZIP Dockerrun.aws.json

  8. @yefim yefim revised this gist May 12, 2016. No changes.
  9. @yefim yefim revised this gist May 12, 2016. 2 changed files with 3 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion Dockerrun.aws.json
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    {
    "AWSEBDockerrunVersion": "1",
    "Image": {
    "Name": "<AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/messaging-worker:<TAG>",
    "Name": "<AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/<NAME>:<TAG>",
    "Update": "true"
    },
    "Ports": [
    3 changes: 2 additions & 1 deletion deploy.sh
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,8 @@ docker push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/$NAME:$VERSION

    # Replace the <AWS_ACCOUNT_ID> with the real ID
    sed -i='' "s/<AWS_ACCOUNT_ID/$AWS_ACCOUNT_ID/" Dockerrun.aws.json

    # Replace the <NAME> with the real name
    sed -i='' "s/<NAME>/$NAME" Dockerrun.aws.json
    # Replace the <TAG> with the real version number
    sed -i='' "s/<TAG>/$VERSION/" Dockerrun.aws.json

  10. @yefim yefim created this gist May 12, 2016.
    12 changes: 12 additions & 0 deletions Dockerrun.aws.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    {
    "AWSEBDockerrunVersion": "1",
    "Image": {
    "Name": "<AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/messaging-worker:<TAG>",
    "Update": "true"
    },
    "Ports": [
    {
    "ContainerPort": "443"
    }
    ]
    }
    43 changes: 43 additions & 0 deletions deploy.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    #!/bin/bash

    # usage: ./deploy.sh staging f0478bd7c2f584b41a49405c91a439ce9d944657

    BRANCH=$1
    SHA1=$2

    AWS_ACCOUNT_ID=12345678900
    NAME=name-of-service-to-deploy
    EB_BUCKET=aws-s3-bucket-to-hold-application-versions

    VERSION=$1-$2

    aws configure set default.region us-east-1

    # Authenticate against our Docker registry
    eval $(aws ecr get-login)

    # Build and push the image
    docker build -t $NAME:$VERSION .
    docker tag $NAME:$VERSION $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/$NAME:$VERSION
    docker push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/$NAME:$VERSION

    # Replace the <AWS_ACCOUNT_ID> with the real ID
    sed -i='' "s/<AWS_ACCOUNT_ID/$AWS_ACCOUNT_ID/" Dockerrun.aws.json

    # Replace the <TAG> with the real version number
    sed -i='' "s/<TAG>/$VERSION/" Dockerrun.aws.json

    ZIP=$VERSION.zip

    # Zip up the Dockerrun file (feel free to zip up an .ebextensions directory with it)
    zip -r $ZIP Dockerrun.aws.json

    aws s3 cp $ZIP s3://$EB_BUCKET/$ZIP

    # Create a new Application Version with the zipped up Dockerrun file
    aws elasticbeanstalk create-application-version --application-name $NAME-application \
    --version-label $VERSION --source-bundle S3Bucket=$EB_BUCKET,S3Key=$ZIP

    # Update the environment to use the new application version
    aws elasticbeanstalk update-environment --environment-name $NAME \
    --version-label $VERSION