2

我正在关注本教程:

https://docs.docker.com/compose/rails/

我想用 PostgreSQL 数据库(Dockerized)创建一个 Ruby On Rails API

但是当我跑步时

docker-compose run web rails new . --force --no-deps --api --database=postgresql

我懂了:

Creating soft-vape-db ... done /usr/bin/entrypoint.sh: line 8: exec: @: not found

入口点.sh

#!/usr/bin/env bash
set -e
rm -f /myapp/tmp/pids/server.pid
exec "$@"

Dockerfile

FROM ruby:2.5
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
RUN mkdir /myapp
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN bundle install
COPY . /myapp

COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000

CMD ["rails", "server", "-b", "0.0.0.0"]

码头工人-compose.yml

version: '3'
services:
  db:
    container_name: soft-vape-db
    image: postgres
    volumes:
      - ./tmp/db:/var/lib/postgresql/data
  web:
    container_name: soft-vape-api
    build: .
    command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
    volumes:
      - .:/myapp
    ports:
      - "3000:3000"
    depends_on:
      - db

任何想法 ?

4

1 回答 1

2

这个问题已经很老了,但是在使用文档中的示例时我也遇到了这个问题,所以我希望这对某人有所帮助。解决方案非常简单。rails new 命令应以 bundle exec.

所以运行docker-compose run web bundle exec rails new . --force --no-deps --api --database=postgresql

于 2019-11-16T11:10:22.240 回答