Reputation: 65
I'm trying to set up gitlab ci using the method documented here and testing a rails 4 app with it.
The problem I'm having is that the test will run once and build the image and containers, but when I try to run the test again it will fail with:
gitlab-ci-multi-runner 1.1.3 (a470667)
Using Shell executor...
Running on ubuntu-lon1-01...
Fetching changes...
warning: failed to remove tmp/miniprofiler
ERROR: Build failed: exit status 1
I think this is because the tmp folder is generated when you run the app a first time and is owned by root in the container.
This is the gitlab.ci.yml
I'm currently using but I've tried lots of different versions all with the same result:
before_script:
- docker info
build_image:
stage: test
script:
- docker-compose build
- docker-compose run web rake db:create RAILS_ENV=test
- docker-compose run web bin/rake db:migrate RAILS_ENV=test
- docker-compose up -d
- docker-compose run web bundle exec rspec
- docker-compose stop
I thought I may be able to delete the folder using the after_script
but that doesn't work with the shell setup.
I'm not sure how to handle this. I think I need to either delete it on exit or change the permissions so it can be deleted.
This is my Dockerfile:
FROM ruby:2.3.1
RUN apt-get update -qq && apt-get install -y build-essential \
&& apt-get install -y apt-utils \
&& apt-get install -y libqt4-webkit libqt4-dev xvfb \
&& apt-get install -y wget \
&& apt-get install -y libpq-dev \
&& apt-get install -y postgresql-contrib \
&& apt-get install -y libxml2-dev libxslt1-dev \
&& apt-get install -y imagemagick libmagickcore-dev libmagickwand-dev \
&& apt-get install -y nodejs
RUN gem install foreman
WORKDIR /tmp
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
RUN bundle install
RUN mkdir /app
WORKDIR /app
COPY . /app/
And my docker-compose:
db:
image: postgres:9.4
ports:
- "5432"
web:
build: .
command: foreman start -f Procfile.dev
volumes:
- .:/app
stdin_open: true
ports:
- "3000:3000"
links:
- db
Googling I can't seem to find anyone that's having the same issue so I'm assuming I'm doing something wrong.
Thanks.
Upvotes: 2
Views: 1027
Reputation: 2752
I thought I may be able to delete the folder using the after_script but that doesn't work with the shell setup.
I had the same issue and solved it by adding this to .gitlab.ci.yml
after_script:
- docker-compose run web rm -rf tmp/
(Using shell runner with gitlab-ci-multi-runner 1.7.1)
Upvotes: 2