1

The dockerfile builds locally but the GitLab pipeline fails, saying:

Step 3/8 : RUN gem install bundler rake
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/local/bundle directory.

The project strucutre is a Ruby Sinatra backend and a React frontend.

The Dockerfile looks like this

FROM ruby:3.0-alpine

# Install Dependencies
RUN apk update && apk add --no-cache build-base mysql-dev rrdtool
RUN gem install bundler rake

# Copy the files and build
WORKDIR /usr/server
COPY . .
RUN bundler install

# Run bundler
EXPOSE 443
CMD ["bundle", "exec", "puma"]

I thought Docker was meant to solve the problem of "it runs on my machine"...

What I've tried

As per this post, I tried adding -n /usr/local/bundle but it did not fix the issue.

bar9833625
  • 295
  • 2
  • 11
  • 1
    did you try specify path for bundler command? `RUN bundler install --path vendor/` also there is https://stackoverflow.com/a/68258603/5347939 some options given, maybe you can try them also – zhisme Oct 27 '21 at 09:35

0 Answers0