From 7989f89202236f760ef63f1681c3ade7100b6093 Mon Sep 17 00:00:00 2001 From: Thomas Riboulet Date: Sun, 8 Mar 2015 20:44:06 +0000 Subject: [PATCH] add more builds --- Sidekiq.Dockerrun.aws.json.template | 16 ++++++++++++++++ Sidekiq_Dockerfile | 13 +++++++++++++ circle.yml | 5 ++++- sidekiq_deploy.sh | 19 +++++++++++++++++++ 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 Sidekiq.Dockerrun.aws.json.template create mode 100644 Sidekiq_Dockerfile create mode 100644 sidekiq_deploy.sh diff --git a/Sidekiq.Dockerrun.aws.json.template b/Sidekiq.Dockerrun.aws.json.template new file mode 100644 index 0000000..94dd8a1 --- /dev/null +++ b/Sidekiq.Dockerrun.aws.json.template @@ -0,0 +1,16 @@ +{ + "AWSEBDockerrunVersion": "1", + "Authentication": { + "Bucket": "elasticbeanstalk-eu-west-1-598354601320", + "Key": "dockercfg" + }, + "Image": { + "Name": "mcansky/sinatra_hello_sidekiq:", + "Update": "true" + }, + "Ports": [ + { + "ContainerPort": "80" + } + ] +} diff --git a/Sidekiq_Dockerfile b/Sidekiq_Dockerfile new file mode 100644 index 0000000..0840819 --- /dev/null +++ b/Sidekiq_Dockerfile @@ -0,0 +1,13 @@ +FROM mcansky/base_ruby:2c7652fa95a2ab9419bb85e81a7c801ca6fa65d2 + +# Set environment variables. +ENV HOME /var/app +ENV RACK_ENV production + +# Define working directory. +WORKDIR /var/app + +RUN git clone https://github.com/mcansky/sinatra_hello.git /var/app +RUN cd /var/app; bundle install + +CMD ["/usr/local/bin/foreman","run", "sidekiq","-d","/var/app"] diff --git a/circle.yml b/circle.yml index e20413c..efd2bdd 100644 --- a/circle.yml +++ b/circle.yml @@ -7,7 +7,6 @@ machine: dependencies: pre: - pip install awscli - - docker build -t mcansky/sinatra_hello:$CIRCLE_SHA1 . test: override: @@ -17,5 +16,9 @@ deployment: hub: branch: master commands: + - docker build -t mcansky/sinatra_hello:$CIRCLE_SHA1 . - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS - ./deploy.sh $CIRCLE_SHA1 + - cp Sidekiq_Dockerfile Dockerfile + - docker build -t mcansky/sinatra_hello_sidekiq:$CIRCLE_SHA1 . + - ./sidekiq_deploy.sh $CIRCLE_SHA1 diff --git a/sidekiq_deploy.sh b/sidekiq_deploy.sh new file mode 100644 index 0000000..062b7a0 --- /dev/null +++ b/sidekiq_deploy.sh @@ -0,0 +1,19 @@ +# deploy.sh +#! /bin/bash + +SHA1=$1 + +# Deploy image to Docker Hub +docker push mcansky/sinatra_hello_sidekiq:$SHA1 + +# Create new Elastic Beanstalk version +EB_BUCKET=elasticbeanstalk-eu-west-1-sidekiq +DOCKERRUN_FILE=$SHA1-Dockerrun.aws.json +sed "s//$SHA1/" < Sidekiq.Dockerrun.aws.json.template > $DOCKERRUN_FILE +aws s3 cp $DOCKERRUN_FILE s3://$EB_BUCKET/$DOCKERRUN_FILE +aws elasticbeanstalk create-application-version --application-name sinatra_hello_sidekiq_eb2 \ + --version-label $SHA1 --source-bundle S3Bucket=$EB_BUCKET,S3Key=$DOCKERRUN_FILE + +# Update Elastic Beanstalk environment to new version +aws elasticbeanstalk update-environment --environment-name sinatraHelloSidekiq-env \ + --version-label $SHA1