gpt4 book ai didi

ruby-on-rails - Sprockets 未拾取 app/assets/builds 文件夹 Rails 7

转载 作者:行者123 更新时间:2023-12-05 09:29:06 30 4
gpt4 key购买 nike

我只是设置了一个空的 Rails 7.0.1 项目并向其中添加了 Docker 文件,当命令 rake assets:precompile 运行时它不包括 app/assets/builds 中的文件 文件夹。

有人知道我做错了什么吗?

app/assets/config/manifest.js

//= link_tree ../images
//= link_tree ../builds

app/assets/config/manifest.js

FROM ruby:3.0.3-slim-bullseye AS assets

WORKDIR /app

RUN bash -c "set -o pipefail && apt-get update \
&& apt-get install -y --no-install-recommends build-essential curl git libpq-dev libsqlite3-dev \
&& curl -sSL https://deb.nodesource.com/setup_16.x | bash - \
&& curl -sSL 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 --no-install-recommends nodejs yarn default-jre \
&& rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \
&& apt-get clean \
&& useradd --create-home ruby \
&& mkdir /node_modules && chown ruby:ruby -R /node_modules /app"

USER ruby

COPY --chown=ruby:ruby Gemfile* ./
RUN bundle install --jobs "$(nproc)"

COPY --chown=ruby:ruby package.json *yarn* ./
RUN yarn install

ARG RAILS_ENV
ARG SECRET_KEY_BASE

ENV NODE_ENV="production" \
PATH="${PATH}:/home/ruby/.local/bin:/node_modules/.bin" \
USER="ruby"

COPY --chown=ruby:ruby . .

RUN ./bin/rails assets:precompile

** 输出 **

2022-01-23T22:45:25.0500519Z Step 13/25 : RUN ./bin/rails assets:precompile
2022-01-23T22:45:25.0830843Z ---> Running in 86e1ba81ff19
2022-01-23T22:45:27.9626041Z yarn install v1.22.17
2022-01-23T22:45:28.0174765Z [1/4] Resolving packages...
2022-01-23T22:45:28.0971605Z [2/4] Fetching packages...
2022-01-23T22:45:28.2027589Z [3/4] Linking dependencies...
2022-01-23T22:45:28.4713925Z [4/4] Building fresh packages...
2022-01-23T22:45:28.4825170Z Done in 0.53s.
2022-01-23T22:45:28.6600447Z yarn run v1.22.17
2022-01-23T22:45:28.6976576Z $ esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds
2022-01-23T22:45:28.7818982Z [91m
2022-01-23T22:45:28.7819369Z app/assets/builds/application.js 188.1kb
2022-01-23T22:45:28.7819727Z app/assets/builds/application.js.map 304.3kb
2022-01-23T22:45:28.7819884Z
2022-01-23T22:45:28.7866507Z [0mDone in 0.13s.
2022-01-23T22:45:28.9660332Z yarn install v1.22.17
2022-01-23T22:45:29.0253735Z [1/4] Resolving packages...
2022-01-23T22:45:29.1031076Z success Already up-to-date.
2022-01-23T22:45:29.1091794Z Done in 0.15s.
2022-01-23T22:45:29.2882888Z yarn run v1.22.17
2022-01-23T22:45:29.3324733Z $ tailwindcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css
2022-01-23T22:45:30.1221872Z [91m
2022-01-23T22:45:30.1227288Z [0m[91mDone in 185ms.
2022-01-23T22:45:30.1365454Z [0mDone in 0.85s.
2022-01-23T22:45:37.4026537Z [91mI, [2022-01-23T22:45:37.401686 #7] INFO -- : Writing /app/public/assets/manifest-04024382391bb910584145d8113cf35ef376b55d125bb4516cebeb14ce788597.js
2022-01-23T22:45:37.4028911Z [0m[91mI, [2022-01-23T22:45:37.401956 #7] INFO -- : Writing /app/public/assets/manifest-04024382391bb910584145d8113cf35ef376b55d125bb4516cebeb14ce788597.js.gz
2022-01-23T22:45:37.4030004Z I, [2022-01-23T22:45:37.402127 #7] INFO -- : Writing /app/public/assets/turbo-568d8de4433dcde538b73d3315800ba326315d7ba9b56c15327824ab6ed16884.js
2022-01-23T22:45:37.4031350Z I, [2022-01-23T22:45:37.402209 #7] INFO -- : Writing /app/public/assets/turbo-568d8de4433dcde538b73d3315800ba326315d7ba9b56c15327824ab6ed16884.js.gz
2022-01-23T22:45:37.4038099Z [0m[91mI, [2022-01-23T22:45:37.402307 #7] INFO -- : Writing /app/public/assets/turbo.min.js-2e71e75cec6429b11d9575a009df6f148e9c52fbae30baf2292ec44620163b6f.map
2022-01-23T22:45:37.4052327Z [0m[91mI, [2022-01-23T22:45:37.404423 #7] INFO -- : Writing /app/public/assets/turbo.min-6124000e16e2a773750df63ac018d8cc0425994af2e997a75846a45f2d9f800f.js
2022-01-23T22:45:37.4053471Z [0m[91mI, [2022-01-23T22:45:37.404672 #7] INFO -- : Writing /app/public/assets/turbo.min-6124000e16e2a773750df63ac018d8cc0425994af2e997a75846a45f2d9f800f.js.gz
2022-01-23T22:45:37.4126829Z [0m[91mI, [2022-01-23T22:45:37.411887 #7] INFO -- : Writing /app/public/assets/activestorage.esm-39b0e74b44e13cff0d2d1a23387629fab136f585c88cb628e38ba66b72c9c2f7.js
2022-01-23T22:45:37.4129836Z [0m[91mI, [2022-01-23T22:45:37.412286 #7] INFO -- : Writing /app/public/assets/activestorage.esm-39b0e74b44e13cff0d2d1a23387629fab136f585c88cb628e38ba66b72c9c2f7.js.gz
2022-01-23T22:45:37.4132792Z [0m[91mI, [2022-01-23T22:45:37.412640 #7] INFO -- : Writing /app/public/assets/activestorage-3673dd642f37129898313c07fcbf2607d11b2cbaf3509e815cbaf84bb1d146f3.js
2022-01-23T22:45:37.4134021Z [0m[91mI, [2022-01-23T22:45:37.412943 #7] INFO -- : Writing /app/public/assets/activestorage-3673dd642f37129898313c07fcbf2607d11b2cbaf3509e815cbaf84bb1d146f3.js.gz
2022-01-23T22:45:37.4136828Z [0m[91mI, [2022-01-23T22:45:37.413281 #7] INFO -- : Writing /app/public/assets/actiontext-7ad159e2b221bb86f7ce063624d6899446d954e0336febb4f07a146d21810095.js
2022-01-23T22:45:37.4140030Z [0m[91mI, [2022-01-23T22:45:37.413578 #7] INFO -- : Writing /app/public/assets/actiontext-7ad159e2b221bb86f7ce063624d6899446d954e0336febb4f07a146d21810095.js.gz
2022-01-23T22:45:37.4145340Z [0m[91mI, [2022-01-23T22:45:37.413906 #7] INFO -- : Writing /app/public/assets/trix-6fd35bb8fae1d6a795115763ca265369b9750f73a1c6283a0b0ef4b6c2d550c8.css
2022-01-23T22:45:37.4146594Z [0m[91mI, [2022-01-23T22:45:37.414196 #7] INFO -- : Writing /app/public/assets/trix-6fd35bb8fae1d6a795115763ca265369b9750f73a1c6283a0b0ef4b6c2d550c8.css.gz
2022-01-23T22:45:37.4149442Z [0m[91mI, [2022-01-23T22:45:37.414545 #7] INFO -- : Writing /app/public/assets/stimulus-8088f1ad4acbb3f63d6f5d901115827ea6afcbce2e457211ef4cbad61a30bbd5.js
2022-01-23T22:45:37.4152276Z [0m[91mI, [2022-01-23T22:45:37.414841 #7] INFO -- : Writing /app/public/assets/stimulus-8088f1ad4acbb3f63d6f5d901115827ea6afcbce2e457211ef4cbad61a30bbd5.js.gz
2022-01-23T22:45:37.4166858Z [0m[91mI, [2022-01-23T22:45:37.415163 #7] INFO -- : Writing /app/public/assets/stimulus-autoloader-7baf25834ba7e290241a8478939900318e18c2eae730b2827e8c1e3d14ac3b91.js
2022-01-23T22:45:37.4170174Z [0m[91mI, [2022-01-23T22:45:37.415459 #7] INFO -- : Writing /app/public/assets/stimulus-autoloader-7baf25834ba7e290241a8478939900318e18c2eae730b2827e8c1e3d14ac3b91.js.gz
2022-01-23T22:45:37.4173172Z [0m[91mI, [2022-01-23T22:45:37.415779 #7] INFO -- : Writing /app/public/assets/stimulus-importmap-autoloader-d932fb7d87bf9b1635447fd97ff64b0ebfc95767b00ca21bb93b7a77d4db3c6e.js
2022-01-23T22:45:37.4174427Z [0m[91mI, [2022-01-23T22:45:37.416195 #7] INFO -- : Writing /app/public/assets/stimulus-importmap-autoloader-d932fb7d87bf9b1635447fd97ff64b0ebfc95767b00ca21bb93b7a77d4db3c6e.js.gz
2022-01-23T22:45:37.4177246Z [0m[91mI, [2022-01-23T22:45:37.416664 #7] INFO -- : Writing /app/public/assets/stimulus-loading-4fe65617eba53d49c46ab6022776f5959fce7c724c0b05aed33d7857083fad0f.js
2022-01-23T22:45:37.4180046Z [0m[91mI, [2022-01-23T22:45:37.416982 #7] INFO -- : Writing /app/public/assets/stimulus-loading-4fe65617eba53d49c46ab6022776f5959fce7c724c0b05aed33d7857083fad0f.js.gz
2022-01-23T22:45:37.4182803Z [0m[91mI, [2022-01-23T22:45:37.417313 #7] INFO -- : Writing /app/public/assets/stimulus.min-16f5ff27fc00daf8243ccbcd3e9936fbd1cbd18a62e565437978640d43cfa9d2.js
2022-01-23T22:45:37.4186368Z [0m[91mI, [2022-01-23T22:45:37.417604 #7] INFO -- : Writing /app/public/assets/stimulus.min-16f5ff27fc00daf8243ccbcd3e9936fbd1cbd18a62e565437978640d43cfa9d2.js.gz
2022-01-23T22:45:37.4189141Z [0m[91mI, [2022-01-23T22:45:37.417925 #7] INFO -- : Writing /app/public/assets/stimulus-autoloader-7baf25834ba7e290241a8478939900318e18c2eae730b2827e8c1e3d14ac3b91.js
2022-01-23T22:45:37.4192142Z [0m[91mI, [2022-01-23T22:45:37.418215 #7] INFO -- : Writing /app/public/assets/stimulus-autoloader-7baf25834ba7e290241a8478939900318e18c2eae730b2827e8c1e3d14ac3b91.js.gz
2022-01-23T22:45:37.4218864Z [0m[91mI, [2022-01-23T22:45:37.418569 #7] INFO -- : Writing /app/public/assets/stimulus-importmap-autoloader-d932fb7d87bf9b1635447fd97ff64b0ebfc95767b00ca21bb93b7a77d4db3c6e.js
2022-01-23T22:45:37.4226461Z [0m[91mI, [2022-01-23T22:45:37.418855 #7] INFO -- : Writing /app/public/assets/stimulus-importmap-autoloader-d932fb7d87bf9b1635447fd97ff64b0ebfc95767b00ca21bb93b7a77d4db3c6e.js.gz
2022-01-23T22:45:37.4227903Z [0m[91mI, [2022-01-23T22:45:37.419172 #7] INFO -- : Writing /app/public/assets/stimulus-loading-4fe65617eba53d49c46ab6022776f5959fce7c724c0b05aed33d7857083fad0f.js
2022-01-23T22:45:37.4229022Z [0m[91mI, [2022-01-23T22:45:37.419453 #7] INFO -- : Writing /app/public/assets/stimulus-loading-4fe65617eba53d49c46ab6022776f5959fce7c724c0b05aed33d7857083fad0f.js.gz
2022-01-23T22:45:37.4230096Z [0m[91mI, [2022-01-23T22:45:37.419775 #7] INFO -- : Writing /app/public/assets/stimulus.min.js-5cdf38f474c7d64a568a43e5de78b4313515aa0e4bd3d13fac297fffeba809f0.map
2022-01-23T22:45:37.4231149Z [0m[91mI, [2022-01-23T22:45:37.420308 #7] INFO -- : Writing /app/public/assets/trix-4919b0f3b3816020c1bc96560dd25f236a529da10c6a9a667cec125e2287e34e.js
2022-01-23T22:45:37.4232350Z [0m[91mI, [2022-01-23T22:45:37.420627 #7] INFO -- : Writing /app/public/assets/trix-4919b0f3b3816020c1bc96560dd25f236a529da10c6a9a667cec125e2287e34e.js.gz
2022-01-23T22:45:37.4233388Z [0m[91mI, [2022-01-23T22:45:37.420954 #7] INFO -- : Writing /app/public/assets/actioncable-77b90bebc5862799354f416cee992fd4f5bc5e34445b0965e4880626d1e5571d.js
2022-01-23T22:45:37.4234467Z [0m[91mI, [2022-01-23T22:45:37.421244 #7] INFO -- : Writing /app/public/assets/actioncable-77b90bebc5862799354f416cee992fd4f5bc5e34445b0965e4880626d1e5571d.js.gz
2022-01-23T22:45:37.4235528Z [0m[91mI, [2022-01-23T22:45:37.421562 #7] INFO -- : Writing /app/public/assets/actioncable.esm-75f01a77b538dec1e0bc91589881d710d8db3f1a5531c4a9c5d31563bddbf257.js
2022-01-23T22:45:37.4236663Z [0m[91mI, [2022-01-23T22:45:37.421850 #7] INFO -- : Writing /app/public/assets/actioncable.esm-75f01a77b538dec1e0bc91589881d710d8db3f1a5531c4a9c5d31563bddbf257.js.gz
2022-01-23T22:45:39.4552910Z [0mRemoving intermediate container 86e1ba81ff19

PS:我正在使用生产环境并也在本地运行 rake assets:precompile 包括 builds 文件夹的内容。

最佳答案

我在使用 Capistrano 部署时遇到了这个问题,并通过将 .keep 文件添加到 app/assets/builds 并将空目录提交给 git 来修复它,而这恰好在 repo 中丢失了。这确保了在 rake assets:precompile 运行时目标版本的构建目录存在。然后 esbuild/webpack 编译的 Assets 被 sprockets 拾取并复制到 public/assets。

关于ruby-on-rails - Sprockets 未拾取 app/assets/builds 文件夹 Rails 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70827412/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com