We are using docker and ECS/ECR on AWS to deploy.
I have a shell script that CircleCI is meant to execute. If I run it locally it runs fine and the image deploys smoothly to Amazon. However if I do the same thing via CircleCI the docker container exits and has this error
/var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/source/git.rb:191:in rescue in load_spec_files': git://github.com/railsconfig/config.git (at master) is not yet checked out. Run
bundle installfirst. (Bundler::GitError) from /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/source/git.rb:188:in
load_spec_files’
from /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/source/path.rb:92:in local_specs' from /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/source/git.rb:159:in
specs’
from /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/lazy_specification.rb:53:in __materialize__' from /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/spec_set.rb:88:in
block in materialize’
from /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/spec_set.rb:85:in map!' from /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/spec_set.rb:85:in
materialize’
from /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/definition.rb:140:in specs' from /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/definition.rb:185:in
specs_for’
from /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/definition.rb:174:in requested_specs' from /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/environment.rb:18:in
requested_specs’
from /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:13:in setup' from /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler.rb:127:in
setup’
from /var/lib/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/setup.rb:18:in <top (required)>' from /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in
require’
from /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require’
Below is our docker file and the shell script - the only thing removed are some sensitive variables. Docker should consistently build across any machine so I am at a loss as to why this is occurring.
Note - if I SSH into the box and manually run the deploy_stage.sh file it RUNS FINE. It is only erroring when CircleCI is executing on deploy script via circle.yml
Dockerfile
FROM phusion/passenger-ruby22:0.9.17
ENV HOME /root
RUN apt-get update -qq
#&& apt-get install -y memcached
RUN apt-get install -y libqtwebkit-dev qt4-qmake
#libxslt-dev libxml2-dev nano
ENV RAILS_ROOT /home/app/app-web
ENV RAILS_ENV staging
# Expose Nginx HTTP service
EXPOSE 80
EXPOSE 443
EXPOSE 3000
# Start Nginx / Passenger
RUN rm -f /etc/service/nginx/down
# Remove the default site
RUN rm /etc/nginx/sites-enabled/default
# Add the nginx site and config
COPY _docker-config/nginx.conf /etc/nginx/sites-enabled/test_app.conf
COPY _docker-config/rails-env.conf /etc/nginx/main.d/rails-env.conf
# Install bundle of gems
WORKDIR /tmp
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
#RUN bundle install --without test production staging
RUN bundle install
# Add the Rails app
ADD . /home/app/app-web
RUN chown -R app:app /home/app/app-web
WORKDIR /home/app/app-web
#RUN rake assets:precompile --trace
CMD ["/usr/local/bin/bundle", "exec", "passenger", "start"]
#RUN set -a && . /home/app/app-web/.env.staging && bundle exec rake assets:precompile --trace
#RUN bundle exec
#rake assets:precompile --trace
Shell Script
#!/usr/bin/env bash
set -e
set -u
set -o pipefail
CIRCLE_SHA12=staging
# more bash-friendly output for jq
JQ="jq --raw-output --exit-status"
#docker build -t app-web:staging .
sudo pip install awscli==1.9.17
curl -L -o ~/bin/jq https://github.com/stedolan/jq/releases/download/jq-1.5rc1/jq-linux-x86_64-static && chmod +x ~/bin/jq
curl -L https://github.com/docker/compose/releases/download/1.5.0/docker-compose-`uname -s`-`uname -m` > ../bin/docker-compose && chmod +x ../bin/docker-compose
aws ecr get-login --region us-east-1 > ./aws_login.sh
chmod u+x aws_login.sh
chmod g+x aws_login.sh
./aws_login.sh
rm aws_login.sh
docker build --rm=false -t app/app-web:$CIRCLE_SHA12 -f Dockerfile.staging . | cat # workaround progress weirdness
#docker login -u $AWS_LOGIN_USER -p $AWS_LOGIN_PASS -e $AWS_LOGIN_URL
docker tag -f app/app-web:$CIRCLE_SHA12 XXXXX.dkr.ecr.us-east-1.amazonaws.com/app-web:staging
echo "Start Image Deploy"
date #Lets time this
docker push XXXXX.dkr.ecr.us-east-1.amazonaws.com/app-web:staging | cat # workaround progress weirdness
echo "Image Deployed"
date #Lets see the end timee
Relevant circle.yml snippet
deployment:
branch: dev-aws2
commands:
- ./deploy_staging.sh