简体   繁体   中英

How to fix bundler not finding Rails inside docker container

I'm trying to run Blazer inside a Docker container and getting an error.

After running

docker-compose up --build

it builds but then I get an error

bundler: command not found: rails
Install missing gem executables with bundle install

What am I doing wrong?

This is the error in my terminal:

Building blazer_app
Step 1/11 : FROM ruby:2.7-slim
 ---> b913dc62d63c
Step 2/11 : RUN apt-get update -qq && apt-get install -y build-essential ruby-full ruby-dev libpq-dev nodejs git
 ---> Using cache
 ---> cd104b8b0995
Step 3/11 : RUN mkdir /blazer
 ---> Using cache
 ---> 408c4379fd33
Step 4/11 : WORKDIR /blazer
 ---> Using cache
 ---> 9523180b9dfb
Step 5/11 : RUN git clone https://github.com/ankane/blazer /blazer
 ---> Using cache
 ---> 74d20e03d0b4
Step 6/11 : ENV BUNDLE_PATH /blazer
 ---> Using cache
 ---> c8baefb8b45e
Step 7/11 : ENV GEM_PATH /blazer
 ---> Using cache
 ---> ca3230326184
Step 8/11 : ENV GEM_HOME /blazer
 ---> Using cache
 ---> fe6dd938bc16
Step 9/11 : RUN gem install bundler
 ---> Using cache
 ---> 92614a0a968b
Step 10/11 : RUN bundle install
 ---> Using cache
 ---> 87ef51235e08
Step 11/11 : CMD bundle exec rails s -p 1000 -b '0.0.0.0'
 ---> Using cache
 ---> 3dbf4d438d4b

Successfully built 3dbf4d438d4b
Successfully tagged blazer_blazer_app:latest
Starting blazer_postgres ... done
Starting blazer_web      ... done
Attaching to blazer_postgres, blazer_web
blazer_postgres | 
blazer_postgres | PostgreSQL Database directory appears to contain a database; Skipping initialization
blazer_postgres | 
blazer_postgres | 2020-02-02 20:31:14.883 UTC [1] LOG:  starting PostgreSQL 12.1 on x86_64-pc-linux-musl, compiled by gcc (Alpine 9.2.0) 9.2.0, 64-bit
blazer_postgres | 2020-02-02 20:31:14.883 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
blazer_postgres | 2020-02-02 20:31:14.883 UTC [1] LOG:  listening on IPv6 address "::", port 5432
blazer_postgres | 2020-02-02 20:31:14.898 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
blazer_postgres | 2020-02-02 20:31:14.925 UTC [20] LOG:  database system was shut down at 2020-02-02 20:31:12 UTC
blazer_postgres | 2020-02-02 20:31:14.929 UTC [1] LOG:  database system is ready to accept connections
blazer_web    | bundler: command not found: rails
blazer_web    | Install missing gem executables with `bundle install`
blazer_web exited with code 127

docker-compose.yml:

version: '3.7'

services:

  blazer_db:
    container_name: blazer_postgres
    image: postgres:12-alpine
    volumes:
      - blazer_db_vol:/blazer_postgres
    ports:
      - "5432:5432"
    networks:
      - bridge_net

  blazer_app:
    container_name: blazer_web
    build: .
    environment:
      DATABASE_URL: "postgres://postgres@db:5432/postgres" # app database
      BLAZER_DATABASE_URL: "postgres://dbuser:dbpass@dbhost:5432/dbname" # target database
    volumes:
      - blazer_app_vol:/blazer
    networks:
      - bridge_net
    depends_on:
      - blazer_db

networks:
  bridge_net:
    driver: bridge

volumes:
  blazer_db_vol:
  blazer_app_vol:

Dockerfile:

FROM ruby:2.7-slim
RUN apt-get update -qq && apt-get install -y build-essential ruby-full ruby-dev libpq-dev nodejs git

RUN mkdir /blazer
WORKDIR /blazer
RUN git clone https://github.com/ankane/blazer /blazer

ENV BUNDLE_PATH /blazer
ENV GEM_PATH /blazer
ENV GEM_HOME /blazer

RUN gem install bundler
RUN bundle install

CMD bundle exec rails s -p 1000 -b '0.0.0.0'

That repository does not include Rails.

I think you want to check the installation details in the Blazer dev project .

他们 Blazer 的作者为 Blazer Docker 创建了一个新项目: https : //github.com/ankane/blazer-docker

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM