【发布时间】:2021-05-15 21:45:14
【问题描述】:
我正在尝试将我的网络应用程序(使用 Ruby on Rails 开发)运行到一个 docker 容器中,并且我有以下 dockerfile:
FROM ruby:3.0.1-alpine
ENV BUNDLER_VERSION=2.0.2
RUN apk add --update --no-cache \
binutils-gold \
build-base \
curl \
file \
g++ \
gcc \
git \
less \
libstdc++ \
libffi-dev \
libc-dev \
linux-headers \
libxml2-dev \
libxslt-dev \
libgcrypt-dev \
make \
netcat-openbsd \
nodejs \
openssl \
pkgconfig \
postgresql-dev \
#python \
tzdata \
yarn
RUN gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)"
RUN gem update --system
WORKDIR /app
# COPY Gemfile Gemfile.lock ./
COPY Gemfile ./
# RUN bundle config build.nokogiri --use-system-libraries
RUN bundle check || bundle install
COPY package.json yarn.lock ./
RUN yarn install --check-files
COPY . ./.
# RUN [ "chown", "$USER", "./entrypoints/docker-entrypoint.sh"]
RUN ["chmod", "-R", "+x", "entrypoints/docker-entrypoint.sh"]
ENTRYPOINT ["sh", "entrypoints/docker-entrypoint.sh"]
使用以下 docker-compose 文件:
version: '3.4'
services:
app:
build:
context: .
dockerfile: Dockerfile
depends_on:
- database
- redis
ports:
- "3000:3000"
volumes:
- .:/app
- gem_cache:/usr/local/bundle/gems
- node_modules:/app/node_modules
env_file: .env
environment:
RAILS_ENV: development
database:
image: postgres:12.1
volumes:
- db_data:/var/lib/postgresql/data
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
redis:
image: redis:5.0.7
sidekiq:
build:
context: .
dockerfile: Dockerfile
depends_on:
- app
- database
- redis
volumes:
- .:/app
- gem_cache:/usr/local/bundle/gems
- node_modules:/app/node_modules
env_file: .env
environment:
RAILS_ENV: development
entrypoint: ./entrypoints/sidekiq-entrypoint.sh
volumes:
gem_cache:
db_data:
node_modules:
我的问题是在图像起点触发“入口点”时,我总是得到app_1 | /bin/sh: can't open 'entrypoints/docker-entrypoint.sh': Permission denied。
如您所见,我将文件的权限更改为我的 docker build 以便能够执行它,但这并不能解决我的问题...
我已经在互联网上搜索过这个问题,对于我看到的所有帖子,chmod 已经解决了这种问题,所以,经过大约 2 小时的“激烈”网络搜索,我需要你的帮助 ^^
注意: docker-entrypoint.sh 文件只包含:
#!/bin/sh
set -e
if [ -f tmp/pids/server.pid ]; then
rm tmp/pids/server.pid
fi
bundle exec rails s -b 0.0.0.0
提前感谢您的帮助!
Br
编辑:在docker-compose 文件中指定的sidekiq-entrypoint.sh 存在同样的问题。
【问题讨论】:
-
volumes:块用来自主机的内容覆盖图像的/app目录;RUN chmod命令被卷安装隐藏。 -
@DavidMaze 坦克为您提供帮助,这解决了我的问题的一部分。我需要解决我的捆绑器的一个问题,所有这些都将正常工作:)
标签: ruby-on-rails ruby linux docker docker-compose