这是我的 Dockerfile
# syntax=docker/dockerfile:1
FROM ruby:3.0.3
RUN apt-get update -qq && apt-get install -y nodejs npm yarn postgresql-client
RUN curl --compressed -o- -L https://yarnpkg.com/install.sh | bash
RUN mkdir /myapp
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN bundle install
RUN rails assets:precompile
COPY . /myapp
RUN npm install -g yarn -y
RUN yarn install
RUN yarn build:css
RUN rails webpacker:install
RUN rails webpacker:clobber
RUN rails webpacker:compile
# Add a script to be executed every time the container starts.
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000
# Start the main process.
CMD ["rails", "server", "-b", "0.0.0.0"]
在我的 package.json 我有以下
"scripts": {
"build:css": "sass ./app/assets/stylesheets/application.bootstrap.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules"
}
当我运行docker-compose build
正常但命令RUN yarn build:css
无效时,builds
文件夹为空。