FROM node:18-alpine as builder
WORKDIR /src
COPY package.json /src
COPY yarn.lock /src
RUN yarn install
COPY . /src
RUN yarn build:css
FROM ruby:3.0.4
WORKDIR /src
COPY Gemfile .
COPY Gemfile.lock .
RUN bundle install
COPY . .
COPY --from=builder /src/app/assets/builds/application.css /src/app/assets/builds/
RUN bundle exec rails assets:precompile
EXPOSE 3000
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]
And I was getting this error:
Step 16/18 : RUN bundle exec rails assets:precompile
---> Running in b268b243b355
sh: 1: yarn: not found
rails aborted!
cssbundling-rails: Command css:build failed, ensure yarn is installed and `yarn build:css` runs without errors or add SKIP_YARN
Tasks: TOP => assets:precompile => css:build
(See full trace by running task with --trace)
Hello,
I was playing with a dockerfile like this:
And I was getting this error:
In this case it makes no sense as the css:build has already be done and the final docker image is free of node/yarn, that's why I'm proposing this
CSS_BUILD=false
similar toWEBPACKER_PRECOMPILE=false
in https://github.com/rails/webpacker/blob/f1b06c7fd5bc4b7fc7128742d1078466b94af71f/lib/tasks/webpacker/compile.rake#L37 to skip the css:build.