Home>

I am trying to introduce Docker into an existing app created with rails6, webpacker4.
When the container is launched, DB connection and HTML display will be done
CSS and bootstrap around the front are not reflected.
Everything around the front has been transferred from the asset pipeline to webpacker.
The fontawesome icon that was read there is displayed, so I think that the webpacker itself is moving,
Why isn't the bootstrap and CSS that are moving to webpacker management reflected?
Please give me advice if you like.

Append

docker-compose run rails where bin/webpack was executed,

ERROR in ./app/fronts/src/stylesheets/application.scss
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
Error: Missing binding /App/node_modules/node-sass/vendor/linux-x64-72/binding.node
Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 12.x
Found bindings for the following environments:
  -OS X 64-bit with Node.js 12.x
.
.
.
Long log with npm rebuild node-sass
.
.
ERROR in ./node_modules/slick-carousel/slick/slick-theme.scss
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
Error: Missing binding /App/node_modules/node-sass/vendor/linux-x64-72/binding.node
Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 12.x
Found bindings for the following environments:
  -OS X 64-bit with Node.js 12.x
Long log with npm rebuild node-sass


It will be displayed.
As the log
docker-compose run rails npm rebuild node-sass was the same error.

Dockerfile
FROM ruby: 2.5.1
RUN rm/bin/sh&&ln -s/bin/bash/bin/sh
RUN apt-get update -qq&&apt-get install -y build-essential libpq-dev
RUN apt-get update&&apt-get install -y curl apt-transport-https wget&&\
    curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add-&&\
    echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list&&\
    apt-get update&&apt-get install -y yarn
RUN curl -SL https://deb.nodesource.com/setup_12.x | bash
RUN apt-get install -y nodejs
RUN apt-get update&&apt-get install -y mysql-client --no-install-recommends&&rm -rf/var/lib/apt/lists/*


RUN mkdir/App
WORKDIR/App
ADD Gemfile/App/Gemfile
ADD Gemfile.lock /App/Gemfile.lock
RUN bundle install
ADD./App
Docker-compose
version: '3'
services:
  rails:
    build:.
    command:/bin/sh -c "rm -f tmp/pids/server.pid&&bundle exec rails s -p 3000 -b '0.0.0.0'"
    volumes:
      -.:/app_name
    ports:
      -"3000: 3000"
    links:
      -db
  db:
    image: mysql: 5.7.28
    environment:
      MYSQL_ROOT_USER: root
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: app_development
    ports:
      -"3306: 3306"
  • Answer # 1

    I solved it with reference to here.
    Since I was ADDing the local as it is, node_modules remains a binary for macOS,
    It seems that an error occurred because the container requires a linux binary.
    It moved when I created dockerignore and did not have node_modules.
    Thank you very much.

Related articles