skip to Main Content

I’m trying to run my web app (developed with Ruby on Rails) into a docker container and I have followings dockerfile :

FROM ruby:3.0.1-alpine


ENV BUNDLER_VERSION=2.0.2

RUN apk add --update --no-cache 
      binutils-gold 
      build-base 
      curl 
      file 
      g++ 
      gcc 
      git 
      less 
      libstdc++ 
      libffi-dev 
      libc-dev 
      linux-headers 
      libxml2-dev 
      libxslt-dev 
      libgcrypt-dev 
      make 
      netcat-openbsd 
      nodejs 
      openssl 
      pkgconfig 
      postgresql-dev 
      #python 
      tzdata 
      yarn

RUN gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)"

RUN gem update --system

WORKDIR /app

# COPY Gemfile Gemfile.lock ./
COPY Gemfile ./

# RUN bundle config build.nokogiri --use-system-libraries

RUN bundle check || bundle install

COPY package.json yarn.lock ./

RUN yarn install --check-files

COPY . ./.

# RUN [ "chown", "$USER", "./entrypoints/docker-entrypoint.sh"]
RUN ["chmod", "-R", "+x", "entrypoints/docker-entrypoint.sh"]

ENTRYPOINT ["sh", "entrypoints/docker-entrypoint.sh"]

with the following docker-compose file :

version: '3.4'

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    depends_on:
      - database
      - redis
    ports:
      - "3000:3000"
    volumes:
      - .:/app
      - gem_cache:/usr/local/bundle/gems
      - node_modules:/app/node_modules
    env_file: .env
    environment:
      RAILS_ENV: development

  database:
    image: postgres:12.1
    volumes:
      - db_data:/var/lib/postgresql/data
      - ./init.sql:/docker-entrypoint-initdb.d/init.sql

  redis:
    image: redis:5.0.7

  sidekiq:
    build:
      context: .
      dockerfile: Dockerfile
    depends_on:
      - app
      - database
      - redis
    volumes:
      - .:/app
      - gem_cache:/usr/local/bundle/gems
      - node_modules:/app/node_modules
    env_file: .env
    environment:
      RAILS_ENV: development
    entrypoint: ./entrypoints/sidekiq-entrypoint.sh

volumes:
  gem_cache:
  db_data:
  node_modules:

My problem is when the "entrypoint" is triggered at the image starting point, I always get app_1 | /bin/sh: can't open 'entrypoints/docker-entrypoint.sh': Permission denied.

As you can see, I change the file’s rights into my docker build to be able to execute it but this not solve my issue…

I’ve searched on the internet about this issue and for all post I saw, the chmod has fixed this kind of problem, so, after about 2h of "intense" web-search, I need your help ^^

Note :
The docker-entrypoint.sh file only contains :

#!/bin/sh

set -e

if [ -f tmp/pids/server.pid ]; then
  rm tmp/pids/server.pid
fi

bundle exec rails s -b 0.0.0.0

Thanks in advance for your help !

Br

Edit : there is the same problem with the sidekiq-entrypoint.sh specified in the docker-compose file.

2

Answers


  1. Try the following

    BUG: Reset entrypoint to override base image.

    ENTRYPOINT []

    CMD entrypoints/docker-entrypoint.sh

    Or even better try just start the server. Just to see if not running the script works

    CMD bundle exec rails s -b 0.0.0.0

    Login or Signup to reply.
  2. Can you try to use RUN ["chmod", "-R", "+x", "./entrypoints/docker-entrypoint.sh"] instead of RUN ["chmod", "-R", "+x", "entrypoints/docker-entrypoint.sh"] and let us know.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search