重建失败:不存在文件 /usr/local/etc/ImageMagick-6/policy.xml

Hi,

I tried to update discourse with ./launcher rebuild app refer from How do I manually update Discourse and Docker image to latest?
But I got failure about ENOENT.

I did below commands to improve this situation.
dpkg-reconfigure -plow unattended-upgrades

apt-get update
apt-get dist-upgrade

wget -qO- https://get.docker.com/ | sh

But the error remained.
I can’t solve it. :sob:

Logs is here.

dstest:/var/discourse$ sudo ./launcher rebuild app
Ensuring launcher is up to date
Fetching origin
Launcher is up-to-date
Stopping old container
+ /usr/bin/docker stop -t 60 app
app
cd /pups && git pull && /pups/bin/pups --stdin
Already up to date.
I, [2020-11-13T07:34:54.569773 #1]  INFO -- : Loading --stdin
I, [2020-11-13T07:34:54.576058 #1]  INFO -- : > locale-gen $LANG && update-locale
I, [2020-11-13T07:34:54.676810 #1]  INFO -- : Generating locales (this might take a while)...
Generation complete.

I, [2020-11-13T07:34:54.677475 #1]  INFO -- : > mkdir -p /shared/postgres_run
I, [2020-11-13T07:34:54.702215 #1]  INFO -- : 
I, [2020-11-13T07:34:54.703054 #1]  INFO -- : > chown postgres:postgres /shared/postgres_run
I, [2020-11-13T07:34:54.712895 #1]  INFO -- : 
I, [2020-11-13T07:34:54.713681 #1]  INFO -- : > chmod 775 /shared/postgres_run
I, [2020-11-13T07:34:54.717105 #1]  INFO -- : 
I, [2020-11-13T07:34:54.717680 #1]  INFO -- : > rm -fr /var/run/postgresql
I, [2020-11-13T07:34:54.719943 #1]  INFO -- : 
I, [2020-11-13T07:34:54.720466 #1]  INFO -- : > ln -s /shared/postgres_run /var/run/postgresql
I, [2020-11-13T07:34:54.723863 #1]  INFO -- : 
I, [2020-11-13T07:34:54.724449 #1]  INFO -- : > socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1
2020/11/13 07:34:54 socat[27] E connect(6, AF=1 "/shared/postgres_run/.s.PGSQL.5432", 36): No such file or directory
I, [2020-11-13T07:34:54.791451 #1]  INFO -- : 
I, [2020-11-13T07:34:54.791940 #1]  INFO -- : > rm -fr /shared/postgres_run/.s*
I, [2020-11-13T07:34:54.795116 #1]  INFO -- : 
I, [2020-11-13T07:34:54.795545 #1]  INFO -- : > rm -fr /shared/postgres_run/*.pid
I, [2020-11-13T07:34:54.798154 #1]  INFO -- : 
I, [2020-11-13T07:34:54.798578 #1]  INFO -- : > mkdir -p /shared/postgres_run/12-main.pg_stat_tmp
I, [2020-11-13T07:34:54.800772 #1]  INFO -- : 
I, [2020-11-13T07:34:54.801357 #1]  INFO -- : > chown postgres:postgres /shared/postgres_run/12-main.pg_stat_tmp
I, [2020-11-13T07:34:54.803400 #1]  INFO -- : 
I, [2020-11-13T07:34:54.807557 #1]  INFO -- : File > /etc/service/postgres/run  chmod: +x  chown: 
I, [2020-11-13T07:34:54.811426 #1]  INFO -- : File > /etc/service/postgres/log/run  chmod: +x  chown: 
I, [2020-11-13T07:34:54.815457 #1]  INFO -- : File > /etc/runit/3.d/99-postgres  chmod: +x  chown: 
I, [2020-11-13T07:34:54.819414 #1]  INFO -- : File > /root/upgrade_postgres  chmod: +x  chown: 
I, [2020-11-13T07:34:54.820021 #1]  INFO -- : > chown -R root /var/lib/postgresql/12/main
I, [2020-11-13T07:34:58.099992 #1]  INFO -- : 
I, [2020-11-13T07:34:58.100865 #1]  INFO -- : > [ ! -e /shared/postgres_data ] && install -d -m 0755 -o postgres -g postgres /shared/postgres_data && sudo -E -u postgres /usr/lib/postgresql/12/bin/initdb -D /shared/postgres_data || exit 0
I, [2020-11-13T07:34:58.103259 #1]  INFO -- : 
I, [2020-11-13T07:34:58.103633 #1]  INFO -- : > chown -R postgres:postgres /shared/postgres_data
I, [2020-11-13T07:34:58.125185 #1]  INFO -- : 
I, [2020-11-13T07:34:58.125939 #1]  INFO -- : > chown -R postgres:postgres /var/run/postgresql
I, [2020-11-13T07:34:58.128600 #1]  INFO -- : 
I, [2020-11-13T07:34:58.129158 #1]  INFO -- : > /root/upgrade_postgres
I, [2020-11-13T07:34:58.133295 #1]  INFO -- : 
I, [2020-11-13T07:34:58.133708 #1]  INFO -- : > rm /root/upgrade_postgres
I, [2020-11-13T07:34:58.135503 #1]  INFO -- : 
I, [2020-11-13T07:34:58.136036 #1]  INFO -- : Replacing data_directory = '/var/lib/postgresql/12/main' with data_directory = '/shared/postgres_data' in /etc/postgresql/12/main/postgresql.conf
I, [2020-11-13T07:34:58.136723 #1]  INFO -- : Replacing (?-mix:#?listen_addresses *=.*) with listen_addresses = '*' in /etc/postgresql/12/main/postgresql.conf
I, [2020-11-13T07:34:58.137998 #1]  INFO -- : Replacing (?-mix:#?synchronous_commit *=.*) with synchronous_commit = $db_synchronous_commit in /etc/postgresql/12/main/postgresql.conf
I, [2020-11-13T07:34:58.138960 #1]  INFO -- : Replacing (?-mix:#?shared_buffers *=.*) with shared_buffers = $db_shared_buffers in /etc/postgresql/12/main/postgresql.conf
I, [2020-11-13T07:34:58.139939 #1]  INFO -- : Replacing (?-mix:#?work_mem *=.*) with work_mem = $db_work_mem in /etc/postgresql/12/main/postgresql.conf
I, [2020-11-13T07:34:58.140867 #1]  INFO -- : Replacing (?-mix:#?default_text_search_config *=.*) with default_text_search_config = '$db_default_text_search_config' i
 /etc/postgresql/12/main/postgresql.conf
I, [2020-11-13T07:34:58.141833 #1]  INFO -- : > install -d -m 0755 -o postgres -g postgres /shared/postgres_backup
I, [2020-11-13T07:34:58.144916 #1]  INFO -- : 
I, [2020-11-13T07:34:58.145559 #1]  INFO -- : Replacing (?-mix:#?checkpoint_segments *=.*) with checkpoint_segments = $db_checkpoint_segments in /etc/postgresql/12/main/postgresql.conf
I, [2020-11-13T07:34:58.146076 #1]  INFO -- : Replacing (?-mix:#?logging_collector *=.*) with logging_collector = $db_logging_collector in /etc/postgresql/12/main/postgresql.conf
I, [2020-11-13T07:34:58.147118 #1]  INFO -- : Replacing (?-mix:#?log_min_duration_statement *=.*) with log_min_duration_statement = $db_log_min_duration_statement in /etc/postgresql/12/main/postgresql.conf
I, [2020-11-13T07:34:58.162784 #1]  INFO -- : Replacing (?-mix:^#local +replication +postgres +peer$) with local replication postgres  peer in /etc/postgresql/12/main/pg_hba.conf
I, [2020-11-13T07:34:58.163691 #1]  INFO -- : Replacing (?-mix:^host.*all.*all.*127.*$) with host all all 0.0.0.0/0 md5 in /etc/postgresql/12/main/pg_hba.conf
I, [2020-11-13T07:34:58.164784 #1]  INFO -- : > HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/12/bin/postmaster -D /etc/postgresql/12/main
I, [2020-11-13T07:34:58.166947 #1]  INFO -- : > sleep 5
2020-11-13 07:34:58.208 UTC [50] LOG:  starting PostgreSQL 12.4 (Debian 12.4-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
2020-11-13 07:34:58.208 UTC [50] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2020-11-13 07:34:58.209 UTC [50] LOG:  listening on IPv6 address "::", port 5432
2020-11-13 07:34:58.218 UTC [50] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2020-11-13 07:34:58.302 UTC [53] LOG:  database system was shut down at 2020-11-13 07:23:18 UTC
2020-11-13 07:34:58.321 UTC [50] LOG:  database system is ready to accept connections
I, [2020-11-13T07:35:03.209924 #1]  INFO -- : 
I, [2020-11-13T07:35:03.222141 #1]  INFO -- : > su postgres -c 'createdb discourse' || true
2020-11-13 07:35:03.575 UTC [63] postgres@postgres ERROR:  database "discourse" already exists
2020-11-13 07:35:03.575 UTC [63] postgres@postgres STATEMENT:  CREATE DATABASE discourse;
createdb: error: database creation failed: ERROR:  database "discourse" already exists
I, [2020-11-13T07:35:03.578465 #1]  INFO -- : 
I, [2020-11-13T07:35:03.578976 #1]  INFO -- : > su postgres -c 'psql discourse -c "create user discourse;"' || true
2020-11-13 07:35:03.644 UTC [74] postgres@discourse ERROR:  role "discourse" already exists
2020-11-13 07:35:03.644 UTC [74] postgres@discourse STATEMENT:  create user discourse;
ERROR:  role "discourse" already exists
I, [2020-11-13T07:35:03.646897 #1]  INFO -- : 
I, [2020-11-13T07:35:03.647407 #1]  INFO -- : > su postgres -c 'psql discourse -c "grant all privileges on database discourse to discourse;"' || true
I, [2020-11-13T07:35:03.711432 #1]  INFO -- : GRANT

I, [2020-11-13T07:35:03.712171 #1]  INFO -- : > su postgres -c 'psql discourse -c "alter schema public owner to discourse;"'
I, [2020-11-13T07:35:03.782199 #1]  INFO -- : ALTER SCHEMA

I, [2020-11-13T07:35:03.782901 #1]  INFO -- : > su postgres -c 'psql template1 -c "create extension if not exists hstore;"'
NOTICE:  extension "hstore" already exists, skipping
I, [2020-11-13T07:35:03.847761 #1]  INFO -- : CREATE EXTENSION

I, [2020-11-13T07:35:03.848327 #1]  INFO -- : > su postgres -c 'psql template1 -c "create extension if not exists pg_trgm;"'
NOTICE:  extension "pg_trgm" already exists, skipping
I, [2020-11-13T07:35:03.909805 #1]  INFO -- : CREATE EXTENSION

I, [2020-11-13T07:35:03.910376 #1]  INFO -- : > su postgres -c 'psql discourse -c "create extension if not exists hstore;"'
NOTICE:  extension "hstore" already exists, skipping
I, [2020-11-13T07:35:03.972494 #1]  INFO -- : CREATE EXTENSION

I, [2020-11-13T07:35:03.973165 #1]  INFO -- : > su postgres -c 'psql discourse -c "create extension if not exists pg_trgm;"'
NOTICE:  extension "pg_trgm" already exists, skipping
I, [2020-11-13T07:35:04.035738 #1]  INFO -- : CREATE EXTENSION

I, [2020-11-13T07:35:04.036418 #1]  INFO -- : > sudo -u postgres psql discourse
I, [2020-11-13T07:35:04.055691 #1]  INFO -- : update pg_database set encoding = pg_char_to_encoding('UTF8') where datname = 'discourse' AND encoding = pg_char_to_encoding('SQL_ASCII');

I, [2020-11-13T07:35:04.147941 #1]  INFO -- : File > /var/lib/postgresql/take-database-backup  chmod: +x  chown: postgres:postgres
I, [2020-11-13T07:35:04.150956 #1]  INFO -- : File > /var/spool/cron/crontabs/postgres  chmod:   chown: 
I, [2020-11-13T07:35:04.151502 #1]  INFO -- : > echo postgres installed!
I, [2020-11-13T07:35:04.167002 #1]  INFO -- : postgres installed!

I, [2020-11-13T07:35:04.172330 #1]  INFO -- : File > /etc/service/redis/run  chmod: +x  chown: 
I, [2020-11-13T07:35:04.176723 #1]  INFO -- : File > /etc/service/redis/log/run  chmod: +x  chown: 
I, [2020-11-13T07:35:04.181121 #1]  INFO -- : File > /etc/runit/3.d/10-redis  chmod: +x  chown: 
I, [2020-11-13T07:35:04.182910 #1]  INFO -- : Replacing daemonize yes with  in /etc/redis/redis.conf
I, [2020-11-13T07:35:04.183837 #1]  INFO -- : Replacing (?-mix:^pidfile.*$) with  in /etc/redis/redis.conf
I, [2020-11-13T07:35:04.185609 #1]  INFO -- : > install -d -m 0755 -o redis -g redis /shared/redis_data
I, [2020-11-13T07:35:04.225330 #1]  INFO -- : 
I, [2020-11-13T07:35:04.226369 #1]  INFO -- : Replacing (?-mix:^logfile.*$) with logfile "" in /etc/redis/redis.conf
I, [2020-11-13T07:35:04.227109 #1]  INFO -- : Replacing (?-mix:^bind .*$) with  in /etc/redis/redis.conf
I, [2020-11-13T07:35:04.229259 #1]  INFO -- : Replacing (?-mix:^dir .*$) with dir /shared/redis_data in /etc/redis/redis.conf
I, [2020-11-13T07:35:04.230796 #1]  INFO -- : Replacing (?-mix:^protected-mode yes) with protected-mode no in /etc/redis/redis.conf
I, [2020-11-13T07:35:04.232306 #1]  INFO -- : Replacing # io-threads 4 with io-threads $redis_io_threads in /etc/redis/redis.conf
I, [2020-11-13T07:35:04.233981 #1]  INFO -- : > echo redis installed
I, [2020-11-13T07:35:04.236684 #1]  INFO -- : redis installed

I, [2020-11-13T07:35:04.237270 #1]  INFO -- : > cat /etc/redis/redis.conf | grep logfile
I, [2020-11-13T07:35:04.263966 #1]  INFO -- : logfile ""

I, [2020-11-13T07:35:04.264740 #1]  INFO -- : > exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf
I, [2020-11-13T07:35:04.266909 #1]  INFO -- : > sleep 10
167:C 13 Nov 2020 07:35:04.374 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
167:C 13 Nov 2020 07:35:04.375 # Redis version=5.0.9, bits=64, commit=00000000, modified=0, pid=167, just started
167:C 13 Nov 2020 07:35:04.375 # Configuration loaded
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 5.0.9 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 167
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

167:M 13 Nov 2020 07:35:04.379 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
167:M 13 Nov 2020 07:35:04.379 # Server initialized
167:M 13 Nov 2020 07:35:04.379 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
167:M 13 Nov 2020 07:35:04.498 * DB loaded from disk: 0.118 seconds
167:M 13 Nov 2020 07:35:04.498 * Ready to accept connections
I, [2020-11-13T07:35:14.270726 #1]  INFO -- : 
I, [2020-11-13T07:35:14.271660 #1]  INFO -- : Terminating async processes
I, [2020-11-13T07:35:14.271971 #1]  INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/12/bin/postmaster -D /etc/postgresql/12/main pid: 50
I, [2020-11-13T07:35:14.272236 #1]  INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 167
2020-11-13 07:35:14.272 UTC [50] LOG:  received fast shutdown request
167:signal-handler (1605252914) Received SIGTERM scheduling shutdown...
2020-11-13 07:35:14.276 UTC [50] LOG:  aborting any active transactions
2020-11-13 07:35:14.278 UTC [50] LOG:  background worker "logical replication launcher" (PID 59) exited with exit code 1
2020-11-13 07:35:14.283 UTC [54] LOG:  shutting down
2020-11-13 07:35:14.312 UTC [50] LOG:  database system is shut down
167:M 13 Nov 2020 07:35:14.331 # User requested shutdown...
167:M 13 Nov 2020 07:35:14.331 * Saving the final RDB snapshot before exiting.
167:M 13 Nov 2020 07:35:14.369 * DB saved on disk
167:M 13 Nov 2020 07:35:14.370 # Redis is now ready to exit, bye bye...

FAILED
--------------------
Errno::ENOENT: No such file or directory @ rb_sysopen - /usr/local/etc/ImageMagick-6/policy.xml
Location of failure: /pups/lib/pups/replace_command.rb:8:in `read'
replace failed with the params {"filename"=>"/usr/local/etc/ImageMagick-6/policy.xml", "from"=>"<policymap>", "to"=>"<policymap>\n  <policy domain=\"coder\" rights=\"none\" pattern=\"EPHEMERAL\" />\n  <policy domain=\"coder\" rights=\"none\" pattern=\"URL\" />\n  <policy domain=\"coder\" rights=\"none\" pattern=\"HTTPS\" />\n  <policy domain=\"coder\" rights=\"none\" pattern=\"MVG\" />\n  <policy domain=\"coder\" rights=\"none\" pattern=\"MSL\" />\n  <policy domain=\"coder\" rights=\"none\" pattern=\"TEXT\" />\n  <policy domain=\"coder\" rights=\"none\" pattern=\"SHOW\" />\n  <policy domain=\"coder\" rights=\"none\" pattern=\"WIN\" />\n  <policy domain=\"coder\" rights=\"none\" pattern=\"PLT\" />\n"}
8a2b7a84ea2ce73e8438d1a8ba1209227b633c0797880d18ca3b5e49d60f1007
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.

你能在这里分享你的 app.yml 文件吗?粘贴内容后,别忘了删除密码。

感谢您的回复。

这是已替换部分词语的 app.yml 文件。

# 这是 Discourse 独立 Docker 容器的全功能模板
##
## 修改此文件后,您必须重新构建
## /var/discourse/launcher rebuild app
##
## 编辑时请*非常*小心!
## YAML 文件对空白字符或缩进错误极其敏感!
## 必要时请访问 http://www.yamllint.com/ 验证此文件

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.custom.yml"
  - "templates/web.ratelimited.template.yml"
## 如果您想添加 Lets Encrypt (https),请取消注释以下两行
  - "templates/web.ssl.template.yml"
  - "templates/web.letsencrypt.ssl.template.yml"

## 此容器应暴露哪些 TCP/IP 端口?
## 如果您希望 Discourse 与另一个 Web 服务器(如 Apache 或 nginx)共享端口,
## 请参阅 https://meta.discourse.org/t/17247 了解详情
expose:
  - "80:80"   # http
  - "443:443" # https

params:
  db_default_text_search_config: "pg_catalog.english"

  ## 将 db_shared_buffers 设置为总内存的最大 25%。
  ## 将根据检测到的 RAM 由 bootstrap 自动设置,您也可以覆盖此设置
  db_shared_buffers: "768MB"

  ## 可改善排序性能,但会增加每个连接的内存使用量
  #db_work_mem: "40MB"

  ## 此容器应使用哪个 Git 版本?(默认:tests-passed)
  version: stable

env:
  LANG: en_US.UTF-8
  # DISCOURSE_DEFAULT_LOCALE: en

  ## 支持多少个并发 Web 请求?取决于内存和 CPU 核心数。
  ## 将根据检测到的 CPU 由 bootstrap 自动设置,您也可以覆盖此设置
  UNICORN_WORKERS: 2

  ## TODO: 此 Discourse 实例将响应的域名
  DISCOURSE_HOSTNAME: bbs.tmp_name.jp

  ## 如果您希望容器以与上述相同的主机名(-h 选项)启动,请取消注释
  ## (默认值为 "$hostname-$config")
  #DOCKER_USE_HOSTNAME: true

  ## TODO: 初始注册时将被设为管理员和开发者的逗号分隔邮箱列表
  ## 示例:'user1@example.com,user2@example.com'
  DISCOURSE_DEVELOPER_EMAILS: 'tmp_name@gmail.com'

  ## TODO: 用于验证新账户和发送通知的 SMTP 邮件服务器
  DISCOURSE_SMTP_ADDRESS: smtp.sendgrid.net
  DISCOURSE_SMTP_PORT: 2525
  DISCOURSE_SMTP_USER_NAME: tmp_name
  DISCOURSE_SMTP_PASSWORD: "*********"
  #DISCOURSE_SMTP_ENABLE_START_TLS: true           # (可选,默认为 true)

  ## 如果您添加了 Lets Encrypt 模板,请取消注释以下行以获取免费 SSL 证书
  LETSENCRYPT_ACCOUNT_EMAIL: tmp_name@gmail.com

  ## 此 Discourse 实例的 CDN 地址(配置为拉取)
  ## 请参阅 https://meta.discourse.org/t/14857 了解详情
  #DISCOURSE_CDN_URL: //discourse-cdn.example.com

## Docker 容器是无状态的;所有数据都存储在 /shared 中
volumes:
  - volume:
      host: /var/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /var/discourse/shared/standalone/log/var-log
      guest: /var/log

## 插件放在这里
## 请参阅 https://meta.discourse.org/t/19157 了解详情
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git

## 构建后运行的任何自定义命令
run:
  - exec: echo "自定义命令开始"
  ## 如果您想为首次注册设置“发件人”电子邮件地址,请取消注释并修改:
  ## 收到首次注册邮件后,请重新注释该行。该行只需运行一次。
  #- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'"
  - exec: echo "自定义命令结束"

感谢 @jamie.wilson 的调查,看来您使用的是过时的安装脚本版本。请尝试运行以下命令:

cd /var/discourse
git pull
./launcher rebuild app

目前这仍会失败,原因是我们正在追踪的另一个 stable 兼容性问题。如果您需要更新,请移除 stable 锁定,因为该锁定目前存在问题,且我们并不频繁测试它。