8000 Rails `config/database.yml` is read from Docker env vars but mysql2 defaults to `root` and ignores `host` and other opts · Issue #211 · phusion/passenger-docker · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
< 8000 div class="position-relative header-wrapper js-header-wrapper "> Skip to content
Rails config/database.yml is read from Docker env vars but mysql2 defaults to root and ignores host and other opts #211
Open
@uchouhan

Description

@uchouhan

I'm running into an issue with the following passenger-docker setup (see below), the rails config/application.rb file does pick up the right env vars passed to the docker run command. However, in the stack trace, mysql2 still tries to connect using root and local socket, ignoring the host, username and password env vars that are passed in

Dockerfile

FROM phusion/passenger-ruby21:0.9.15

ENV HOME /root
CMD ["/sbin/my_init"]

EXPOSE 80

RUN rm -f /etc/service/nginx/down
RUN rm /etc/nginx/sites-enabled/default
ADD nginx.conf /etc/nginx/sites-enabled/appname.conf
ADD rails-env.conf /etc/nginx/main.d/rails-env.conf

WORKDIR /tmp
ADD Gemfile /tmp/
ADD Gemfile.lock /tmp/
RUN bundle install

ADD . /home/app/appname
RUN chown -R app:app /home/app/appname

RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

nginx.conf

server {
  listen 80;
  server_name appname.optimispt.local;
  root /home/app/appname/public;
  passenger_enabled on;
  passenger_user app;
  passenger_ruby /usr/bin/ruby2.1;
}

rails-env.conf

env PASSENGER_APP_ENV;
env RACK_ENV;
env RAILS_ENV;
env SECRET_KEY_BASE;
env DB;
env DB_USER;
env DB_PASS;
env DB_HOST;

The docker command is docker run -d -e PASSENGER_APP_ENV=development -e DB=appname_development -e DB_USER=user -e DB_PASS=pass -e DB_HOST=10.0.2.2 -p 80:80

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0