错误消息:W:缺少用于解密文件的加密密钥。向您的团队询问您的主密钥并将其写入 /app/config/master.key 或将其放入 ENV['RAILS_MASTER_KEY']。
在 Platform.sh 上部署我的项目时,由于缺少解密密钥,操作失败。从我的谷歌搜索中,我发现了解密密钥。
我的 .bashrc
export RAILS_MASTER_KEY='ad5e30979672cdcc2dd4f4381704292a'
PLATFORM.SH 的 rails 项目配置
. 平台.app.yaml
# The name of this app. Must be unique within a project.
name: app
type: 'ruby:2.7'
# The size of the persistent disk of the application (in MB).
disk: 5120
mounts:
'web/uploads':
source: local
source_path: uploads
relationships:
postgresdatabase: 'dbpostgres:postgresql'
hooks:
build: |
gem install bundler:2.2.5
bundle install
RAILS_ENV=production bundle exec rake assets:precompile
deploy: |
RACK_ENV=production bundle exec rake db:migrate
web:
upstream:
socket_family: "unix"
commands:
start: "\"unicorn -l $SOCKET -E production config.ru\""
locations:
'/':
root: "\"public\""
passthru: true
expires: "24h"
allow: true
路线.yaml
# Each route describes how an incoming URL is going to be processed by Platform.sh.
"https://www.{default}/":
type: upstream
upstream: "app:http"
"https://{default}/":
type: redirect
to: "https://www.{default}/"
服务.yaml
# The name given to the PostgreSQL service (lowercase alphanumeric only).
dbpostgres:
type: postgresql:13
# The disk attribute is the size of the persistent disk (in MB) allocated to the service.
disk: 5120
db:
type: postgresql:13
disk: 5120
configuration:
extensions:
- pgcrypto
- plpgsql
- uuid-ossp
环境/生产.rb
config.require_master_key = true
我怀疑在部署过程中无法访问master.key,我不明白如何解决问题。