当我尝试在ec2实例上运行rake db:migrate
时遇到以下错误。我有一个RDS postgres实例。
Errno::EACCES: Permission denied @ rb_sysopen - /app/db/schema.rb
**
以下是我的Dockerfile的相关内容
FROM ubuntu:18.04
RUN apt-get update
RUN useradd -m deploy
WORKDIR /app
RUN mkdir -p vendor
COPY vendor/cache vendor/cache
RUN bundle install --deployment --local --without test development
COPY . .
RUN SECRET_KEY_BASE=111 RAILS_ENV=production bin/rake assets:precompile
RUN mkdir -p tmp/pids
RUN chown -R deploy tmp log
USER deploy
ENV RAILS_LOG_TO_STDOUT 1
EXPOSE 3000
CMD bin/rake db:migrate && bundle exec passenger start --address 0.0.0.0 --port 3000 --auto --disable-anonymous-telemetry -e production
这是我的部署Yaml文件
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: eks-learning-backend
spec:
template:
metadata:
labels:
name: eks-learning-backend
spec:
containers:
- name: rails-app
image: zzz.us-east-1.amazonaws.com/eks:16
env:
- name: EKS_DATABASE_NAME
valueFrom:
secretKeyRef:
name: database-config
key: database_name
- name: EKS_DATABASE_HOST
value: zzz.us-east-1.rds.amazonaws.com
- name: EKS_DATABASE_USERNAME
valueFrom:
secretKeyRef:
name: database-config
key: username
- name: EKS_DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: database-config
key: password
- name: RAILS_MASTER_KEY
value: zzxx
- name: RAILS_ENV
valueFrom:
fieldRef:
fieldPath: metadata.namespace
在这方面的任何帮助都将非常棒!谢谢。
答案 0 :(得分:0)
问题是用户权限不足。您仅包含了RUN chown -R deploy tmp log
,同时还需要授予其对/app/db/
目录的访问权限。
为数据库目录添加其他chown
将解决此问题。