gpt4 book ai didi

ruby-on-rails - Ruby 2.7 和 Rails 7 的 Docker 配置

转载 作者:行者123 更新时间:2023-12-04 19:25:22 25 4
gpt4 key购买 nike

在将 Rails 应用程序升级到 Rails 7 后,我正在尝试将其容器化
下面是我的 docker 文件的相关部分


FROM ubuntu:20.04

#https://www.postgresql.org/download/linux/ubuntu/
RUN apt-get update && apt-get install -y gnupg wget
RUN echo "deb http://apt.postgresql.org/pub/repos/apt bionic-pgdg main" > /etc/apt/sources.list.d/pgdg.list
# Import the repository signing key:
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -

RUN apt-get update && apt-get dist-upgrade -y && DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs ruby-dev bundler build-essential zlib1g-dev libpq-dev tzdata git curl postgresql-client-12 imagemagick && rm -rf /var/lib/apt/lists/*

RUN useradd -m deploy

WORKDIR /app

COPY Gemfile* ./
RUN mkdir -p vendor
COPY vendor/cache vendor/cache
RUN bundle config set deployment 'true'
RUN bundle config set without 'test development'
RUN bundle install
我看到以下错误
#17 1.447 Don't run Bundler as root. Bundler can ask for sudo if it is needed, and                                                                                                                              
#17 1.447 installing your bundle as root will break this application for all non-root
#17 1.447 users on this machine.
#17 2.044 Some gems seem to be missing from your vendor/cache directory.
#17 2.044 Could not find rake-13.0.6 in any of the sources
------
executor failed running [/bin/sh -c bundle install]: exit code: 7
关于如何解决这个问题的任何帮助都会非常棒,谢谢。

最佳答案

添加用户后,您需要切换到它以使后续命令不再以 root 身份运行:

RUN useradd -m deploy
USER deploy

关于ruby-on-rails - Ruby 2.7 和 Rails 7 的 Docker 配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71680772/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com