rails paths are broken in docker container

86 Views Asked by At

I have a rails project which on rails s loads and runs fine. but when I containerize the application, required modules in lib folder are not loaded and could be not found in the docker file structure. how to correctly specify the paths? I dont want to have differentiate between docker and local filesystem.

I have tried different approaches but all of them are pointing to wrong directory

#application.rb
config.autoload_paths += %W(#{config.root}/lib)
RUN mkdir -p /app
WORKDIR /app
COPY . .
RUN bundle install
#my_constants.rb (in config/initializers)
require_relative "#{Rails.root}/app/lib/sf"
PI = 3.14

when i ran in docker, the path in require is always one more /app deeper no matter I do.

is there any good tutorial for that? I am very confused. can somebody help me? thank you.

I have tried different approaches but all of them are pointing to wrong directory. I dont want to have differentiate between docker and local filesystem.

0

There are 0 best solutions below