【发布时间】:2021-04-20 14:04:28
【问题描述】:
我从事 Rails 项目,使用 Webpack 捆绑资产。每次对 JS 或 CSS 进行更改时,我都会运行 docker-compose exec web bundle exec rake assets:precompile; 来编译所有资产。
之后,我必须重新启动 docker 容器,然后运行 docker-compose exec web bundle exec npm run dev;
只有在那之后,我才能看到变化,并且最多可能需要 10 分钟。我错过了什么?如何加快开发过程?
我的 docker-compose.yml:
version: '2'
services:
chromedriver:
image: selenium/standalone-chrome-debug
volumes:
# use hosts shared memory to prevent crashes
# https://github.com/SeleniumHQ/docker-selenium
- /dev/shm:/dev/shm
postgres:
image: postgis/postgis:12-3.0
volumes:
- ./bin/docker/postgres/init-test-db.sh:/docker-entrypoint-initdb.d/init-test-db.sh
- .:/project
logging:
driver: "json-file"
options:
max-size: "10k"
max-file: "1"
redis:
image: redis:5.0.5
logging:
driver: "json-file"
options:
max-size: "10k"
max-file: "1"
worker:
build: .
volumes:
- .:/usr/src/app
- bundle-cache:/usr/local/bundle
command: bundle exec sidekiq
logging:
driver: "json-file"
options:
max-size: "100k"
max-file: "1"
web:
tty: true
stdin_open: true
build: .
volumes:
- .:/usr/src/app
- bundle-cache:/usr/local/bundle
logging:
driver: "json-file"
options:
max-size: "10k"
max-file: "1"
volumes:
bundle-cache:
【问题讨论】:
-
我对 docker 没有太多经验,但是没有它,我运行命令
bin/webpack-dev-server来启动一个服务器,它可以监视 js 或 css 的变化,重新编译它们,然后重新加载页面跨度> -
请分享您的
docker-compose.yml文件以帮助了解您的背景
标签: ruby-on-rails docker webpack