恢复:维护最新的开发环境

哎呀!我发誓我至少尝试过

asdf plugin update ruby

但看起来我也没有做到。 :crying_cat_face: :person_shrugging:

但现在,我真的很接近了!这是我用于拉取 Discourse、更新 Ruby、imagemagick 和 nodejs 并迁移数据库的脚本。

DISCOURSE_SRC=/home/pfaffman/src/discourse-repos/discourse
DISCOURSE_DOCKER_SRC=/home/pfaffman/src/discourse-repos/discourse_docker
cd $DISCOURSE_SRC

  git -C $DISCOURSE_DOCKER_SRC pull https://github.com/discourse/discourse_docker
  DISCOURSE_BASE=$(grep -e ^image= $DISCOURSE_DOCKER_SRC/launcher|cut -d'\"' -f2)
  cd -

  docker pull $DISCOURSE_BASE
  asdf plugin add nodejs #https://github.com/asdf-vm/asdf-nodejs.git
  asdf plugin add ruby #https://github.com/asdf-vm/asdf-ruby.git
  asdf plugin add imagemagick
  asdf plugin update --all
  RUBY_VERSION=$(grep -e ^RUBY_VERSION $DISCOURSE_DOCKER_SRC/image/base/install-ruby|cut -d'\"' -f2)
  asdf install ruby $RUBY_VERSION
  asdf local ruby $RUBY_VERSION
  IMAGE_MAGICK_VERSION=$(grep -e ^IMAGE_MAGICK_VERSION ~//src/discourse-repos/discourse_docker/image/base/install-imagemagick|cut -d'\"' -f2)
  asdf install imagemagick $IMAGE_MAGICK_VERSION
  asdf local imagemagick $IMAGE_MAGICK_VERSION
  # 2023-04-24 debian and pop!os have different nodejs versions
  NODE_VERSION=$(docker run discourse/base:2.0.20230420-0104 bash -c 'node --version'|cut -d'v' -f2)
  asdf install nodejs $NODE_VERSION
  asdf local nodejs $NODE_VERSION
  cd $DISCOURSE_SRC
  git checkout main
  git pull
  bundle install
  ./bin/rake db:migrate
  RAILS_ENV=test ./bin/rake db:migrate

我认为手动跟进 redis 和 postgres 没问题,尽管下次我进行操作系统安装并发现我的操作系统和 Discourse 已分叉时,我可能会改变主意!

我不清楚 oxipng 到底是什么,但认为错误的版本不太可能给插件开发者带来问题。jemalloc 也是如此。

而且说实话,我不确定有多少插件开发者可能会受到 imagemagick 版本的影响。我认为只有 Ruby 和 nodejs 可能会成为障碍。

也许从镜像中获取 ruby 和 imagemagick 版本会更安全,因为我怀疑当 debian 拥有所需的 Ruby 版本时,该脚本就会消失,但当我得知必须从基础镜像中拉取 node 版本时,我已经编写了该逻辑。

而且在我与 @falcoasdf plugin update --all 拯救我之间,以及我编写此脚本之间的时间里,Ruby 版本已升级到 3.2.2,我的代码捕捉到了它,并且 asdf 安装了它!我已经将上面的代码添加到我的更新脚本中,其中包括:

1 个赞