failed to load command: rake on Rails Kubernetes

4/24/2020

I'm trying to deploy a Rails app to Kubernetes but my entrypoint script tries to run rake commands which results in an error.

+ stat -c %u /opt/consul/Gemfile
+ USER_UID=0
+ stat -c %g /opt/consul/Gemfile
+ USER_GID=0
+ export USER_UID
+ export USER_GID
+ usermod -u 0 consul
+ groupmod -g 0 consul
+ usermod -g 0 consul
+ rm -rf /opt/consul/tmp/pids/server.pid
+ set -e
+ bundle exec rake db:create
bundler: failed to load command: rake (/usr/local/bin/rake)

The most annoying part is that if I run

docker-compose up

everything starts up normally. The problem just happens on Kubernetes

docker stack deploy --orchestrator=kubernetes -c docker-compose.yml consul

Most of the files are pretty similar to the ones on the official Consul repo (https://github.com/consul/consul)

I just made some minor changes on versions to make things work with Docker

Already tried syslink files to /usr/bin, add project's bin folder to $PATH

What am I missing?

I will leave some files I think it is important to identify the problem

Here is my Gemfile

source "https://rubygems.org"

gem "rails", "5.0.7.2"

gem "acts-as-taggable-on", "~> 5.0.0"
gem "acts_as_votable", "~> 0.11.1"
gem "ahoy_matey", "~> 1.6.0"
gem "ancestry", "~> 3.0.7"
gem "audited", "~> 4.9.0"
gem "autoprefixer-rails", "~> 8.2.0"
gem "cancancan", "~> 2.3.0"
gem "ckeditor", "~> 4.3.0"
gem "cocoon", "~> 1.2.9"
gem "daemons", "~> 1.2.4"
gem "dalli", "~> 2.7.6"
gem "delayed_job_active_record", "~> 4.1.3"
gem "devise", "~> 4.7.1"
gem "devise-async", "~> 1.0.0"
gem "devise_security_extension", git: "https://github.com/phatworx/devise_security_extension.git" #, "~> 0.10"
gem "font-awesome-sass", "~> 5.8.1"
gem "foundation-rails", "~> 6.6.1.0"
gem "foundation_rails_helper", "~> 3.0.0"
gem "globalize", "~> 5.2.0"
gem "globalize-accessors", "~> 0.2.1"
gem "graphiql-rails", "~> 1.4.1"
gem "graphql", "~> 1.7.8"
gem "groupdate", "~> 3.2.0"
gem "initialjs-rails", "~> 0.2.0.5"
gem "invisible_captcha", "~> 0.10.0"
gem "jquery-fileupload-rails"
gem "jquery-rails", "~> 4.3.3"
gem "jquery-ui-rails", "~> 6.0.1"
gem "kaminari", "~> 1.1.1"
gem "newrelic_rpm", "~> 4.1.0.333"
gem "omniauth", "~> 1.9.0"
gem "omniauth-facebook", "~> 4.0.0"
gem "omniauth-google-oauth2", "~> 0.4.0"
gem "omniauth-rails_csrf_protection", "~> 0.1.2"
gem "omniauth-twitter", "~> 1.4.0"
gem "paperclip", "~> 5.2.1"
gem "paranoia", "~> 2.4.2"
gem "pg", "~> 0.21.0"
gem "pg_search", "~> 2.0.1"
gem "puma", "~> 4.3.3"
gem "recipient_interceptor", "~> 0.2.0"
gem "redcarpet", "~> 3.4.0"
gem "responders", "~> 2.4.0"
gem "rinku", "~> 2.0.2", require: "rails_rinku"
gem "rollbar", "~> 2.18.0"
gem "sassc-rails", "~> 2.1.2"
gem "savon", "~> 2.12.0"
gem "sitemap_generator", "~> 6.0.2"
gem "social-share-button", "~> 1.1"
gem "sprockets", "~> 3.7.2"
gem "translator-text", "~> 0.1.0"
gem "turbolinks", "~> 2.5.3"
gem "turnout", "~> 2.4.0"
gem "uglifier", "~> 4.1.2"
gem "whenever", "~> 0.10.0", require: false
gem "wicked_pdf", "~> 1.1.0"
gem "wkhtmltopdf-binary", "~> 0.12.4"

source "https://rails-assets.org" do
  gem "rails-assets-leaflet"
  gem "rails-assets-markdown-it", "~> 8.2.1"
end

group :development, :test do
  gem "bullet", "~> 5.7.0"
  gem "byebug", "~> 10.0.0"
  gem "factory_bot_rails", "~> 4.8.2"
  gem "faker", "~> 1.8.7"
  gem "i18n-tasks", "~> 0.9.29"
  gem "knapsack_pro", "~> 1.15.0"
  gem "launchy", "~> 2.4.3"
  gem "letter_opener_web", "~> 1.3.4"
  gem "spring", "~> 2.0.1"
  gem "spring-commands-rspec", "~> 1.0.4"
end

group :test do
  gem "capybara", "~> 2.17.0"
  gem "capybara-webmock", "~> 0.5.3"
  gem "coveralls", "~> 0.8.22", require: false
  gem "database_cleaner", "~> 1.7.0"
  gem "email_spec", "~> 2.2.0"
  gem "rspec-rails", "~> 3.8"
  gem "selenium-webdriver", "~> 3.141"
end

group :development do
  gem "capistrano", "~> 3.10.1", require: false
  gem "capistrano-bundler", "~> 1.2", require: false
  gem "capistrano-rails", "~> 1.4.0", require: false
  gem "capistrano3-delayed-job", "~> 1.7.3"
  gem "capistrano3-puma", "~> 4.0.0"
  gem "erb_lint", require: false
  gem "github_changelog_generator", "~> 1.15.0"
  gem "mdl", "~> 0.5.0", require: false
  gem "rubocop", "~> 0.75.0", require: false
  gem "rubocop-performance", "~> 1.4.1", require: false
  gem "rubocop-rails", "~> 2.3.2", require: false
  gem "rubocop-rspec", "~> 1.35.0", require: false
  gem "rvm1-capistrano3", "~> 1.4.0", require: false
  gem "scss_lint", "~> 0.55.0", require: false
  gem "web-console", "~> 3.3.0"
end

eval_gemfile "./Gemfile_custom"

Here is my Gemfile.lock

GIT
  remote: https://github.com/phatworx/devise_security_extension.git
  revision: b2ee978af7d49f0fb0e7271c6ac074dfb4d39353
  specs:
    devise_security_extension (0.10.0)
      devise (>= 3.0.0, < 5.0)
      railties (>= 3.2.6, < 6.0)

GEM
  remote: https://rubygems.org/
  remote: https://rails-assets.org/
  specs:
    actioncable (5.0.7.2)
      actionpack (= 5.0.7.2)
      nio4r (>= 1.2, < 3.0)
      websocket-driver (~> 0.6.1)
    actionmailer (5.0.7.2)
      actionpack (= 5.0.7.2)
      actionview (= 5.0.7.2)
      activejob (= 5.0.7.2)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 2.0)
    actionpack (5.0.7.2)
      actionview (= 5.0.7.2)
      activesupport (= 5.0.7.2)
      rack (~> 2.0)
      rack-test (~> 0.6.3)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    actionview (5.0.7.2)
      activesupport (= 5.0.7.2)
      builder (~> 3.1)
      erubis (~> 2.7.0)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.3)
    activejob (5.0.7.2)
      activesupport (= 5.0.7.2)
      globalid (>= 0.3.6)
    activemodel (5.0.7.2)
      activesupport (= 5.0.7.2)
    activerecord (5.0.7.2)
      activemodel (= 5.0.7.2)
      activesupport (= 5.0.7.2)
      arel (~> 7.0)
    activesupport (5.0.7.2)
      concurrent-ruby (~> 1.0, >= 1.0.2)
      i18n (>= 0.7, < 2)
      minitest (~> 5.1)
      tzinfo (~> 1.1)
    acts-as-taggable-on (5.0.0)
      activerecord (>= 4.2.8)
    acts_as_votable (0.11.1)
    addressable (2.7.0)
      public_suffix (>= 2.0.2, < 5.0)
    ahoy_matey (1.6.0)
      addressable
      browser (~> 2.0)
      geocoder
      rack-attack (< 6)
      railties
      referer-parser (>= 0.3.0)
      request_store
      safely_block (>= 0.1.1)
      user_agent_parser
      uuidtools
    airbrussh (1.3.0)
      sshkit (>= 1.6.1, != 1.7.0)
    akami (1.3.1)
      gyoku (>= 0.4.0)
      nokogiri
    ancestry (3.0.7)
      activerecord (>= 3.2.0)
    arel (7.1.4)
    ast (2.4.0)
    audited (4.9.0)
      activerecord (>= 4.2, < 6.1)
    autoprefixer-rails (8.2.0)
      execjs
    babel-source (5.8.35)
    babel-transpiler (0.7.0)
      babel-source (>= 4.0, < 6)
      execjs (~> 2.0)
    bcrypt (3.1.13)
    better_html (1.0.13)
      actionview (>= 4.0)
      activesupport (>= 4.0)
      ast (~> 2.0)
      erubi (~> 1.4)
      html_tokenizer (~> 0.0.6)
      parser (>= 2.4)
      smart_properties
    browser (2.5.3)
    builder (3.2.4)
    bullet (5.7.1)
      activesupport (>= 3.0.0)
      uniform_notifier (~> 1.11.0)
    byebug (10.0.0)
    cancancan (2.3.0)
    capistrano (3.10.1)
      airbrussh (>= 1.0.0)
      i18n
      rake (>= 10.0.0)
      sshkit (>= 1.9.0)
    capistrano-bundler (1.3.0)
      capistrano (~> 3.1)
      sshkit (~> 1.2)
    capistrano-rails (1.4.0)
      capistrano (~> 3.1)
      capistrano-bundler (~> 1.1)
    capistrano3-delayed-job (1.7.5)
      capistrano (~> 3.0, >= 3.0.0)
      daemons (~> 1.2.4)
    capistrano3-puma (4.0.0)
      capistrano (~> 3.7)
      capistrano-bundler
      puma (~> 4.0)
    capybara (2.17.0)
      addressable
      mini_mime (>= 0.1.3)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      xpath (>= 2.0, < 4.0)
    capybara-webmock (0.5.3)
      capybara (>= 2.4, < 4)
      rack (>= 1.4)
      rack-proxy (>= 0.6.0)
      selenium-webdriver (~> 3.0)
    childprocess (0.9.0)
      ffi (~> 1.0, >= 1.0.11)
    chronic (0.10.2)
    ckeditor (4.3.0)
      orm_adapter (~> 0.5.0)
      terrapin
    climate_control (0.2.0)
    cocaine (0.5.8)
      climate_control (>= 0.0.3, < 1.0)
    cocoon (1.2.11)
    coffee-rails (4.2.2)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0)
    coffee-script (2.4.1)
      coffee-script-source
      execjs
    coffee-script-source (1.12.2)
    concurrent-ruby (1.1.5)
    coveralls (0.8.22)
      json (>= 1.8, < 3)
      simplecov (~> 0.16.1)
      term-ansicolor (~> 1.3)
      thor (~> 0.19.4)
      tins (~> 1.6)
    crass (1.0.6)
    daemons (1.2.6)
    dalli (2.7.6)
    database_cleaner (1.7.0)
    debug_inspector (0.0.3)
    delayed_job (4.1.5)
      activesupport (>= 3.0, < 5.3)
    delayed_job_active_record (4.1.3)
      activerecord (>= 3.0, < 5.3)
      delayed_job (>= 3.0, < 5)
    devise (4.7.1)
      bcrypt (~> 3.0)
      orm_adapter (~> 0.1)
      railties (>= 4.1.0)
      responders
      warden (~> 1.2.3)
    devise-async (1.0.0)
      activejob (>= 5.0)
      devise (>= 4.0)
    diff-lcs (1.3)
    docile (1.3.1)
    dry-configurable (0.7.0)
      concurrent-ruby (~> 1.0)
    dry-container (0.6.0)
      concurrent-ruby (~> 1.0)
      dry-configurable (~> 0.1, >= 0.1.3)
    dry-core (0.4.7)
      concurrent-ruby (~> 1.0)
    dry-equalizer (0.2.1)
    dry-inflector (0.1.2)
    dry-logic (0.4.2)
      dry-container (~> 0.2, >= 0.2.6)
      dry-core (~> 0.2)
      dry-equalizer (~> 0.2)
    dry-struct (0.5.1)
      dry-core (~> 0.4, >= 0.4.3)
      dry-equalizer (~> 0.2)
      dry-types (~> 0.13)
      ice_nine (~> 0.11)
    dry-types (0.13.3)
      concurrent-ruby (~> 1.0)
      dry-container (~> 0.3)
      dry-core (~> 0.4, >= 0.4.4)
      dry-equalizer (~> 0.2)
      dry-inflector (~> 0.1, >= 0.1.2)
      dry-logic (~> 0.4, >= 0.4.2)
    email_spec (2.2.0)
      htmlentities (~> 4.3.3)
      launchy (~> 2.1)
      mail (~> 2.7)
    erb_lint (0.0.28)
      activesupport
      better_html (~> 1.0.7)
      html_tokenizer
      rainbow
      rubocop (~> 0.51)
      smart_properties
    errbase (0.0.3)
    erubi (1.8.0)
    erubis (2.7.0)
    execjs (2.7.0)
    factory_bot (4.8.2)
      activesupport (>= 3.0.0)
    factory_bot_rails (4.8.2)
      factory_bot (~> 4.8.2)
      railties (>= 3.0.0)
    faker (1.8.7)
      i18n (>= 0.7)
    faraday (0.12.2)
      multipart-post (>= 1.2, < 3)
    faraday-http-cache (2.0.0)
      faraday (~> 0.8)
    ffi (1.11.1)
    font-awesome-sass (5.8.1)
      sassc (>= 1.11)
    foundation-rails (6.6.1.0)
      railties (>= 3.1.0)
      sass (>= 3.3.0)
      sprockets-es6 (>= 0.9.0)
    foundation_rails_helper (3.0.0)
      actionpack (>= 4.1, < 6.0)
      activemodel (>= 4.1, < 6.0)
      activesupport (>= 4.1, < 6.0)
      railties (>= 4.1, < 6.0)
      tzinfo (~> 1.2, >= 1.2.2)
    geocoder (1.4.5)
    github_changelog_generator (1.15.0)
      activesupport
      faraday-http-cache
      multi_json
      octokit (~> 4.6)
      rainbow (>= 2.2.1)
      rake (>= 10.0)
      retriable (~> 3.0)
    globalid (0.4.2)
      activesupport (>= 4.2.0)
    globalize (5.2.0)
      activemodel (>= 4.2, < 5.3)
      activerecord (>= 4.2, < 5.3)
      request_store (~> 1.0)
    globalize-accessors (0.2.1)
      globalize (~> 5.0, >= 5.0.0)
    graphiql-rails (1.4.8)
      rails
    graphql (1.7.8)
    groupdate (3.2.0)
      activesupport (>= 3)
    gyoku (1.3.1)
      builder (>= 2.1.2)
    hashie (3.6.0)
    highline (2.0.2)
    html_tokenizer (0.0.7)
    htmlentities (4.3.4)
    httparty (0.17.0)
      mime-types (~> 3.0)
      multi_xml (>= 0.5.2)
    httpi (2.4.4)
      rack
      socksify
    i18n (0.9.5)
      concurrent-ruby (~> 1.0)
    i18n-tasks (0.9.29)
      activesupport (>= 4.0.2)
      ast (>= 2.1.0)
      erubi
      highline (>= 2.0.0)
      i18n
      parser (>= 2.2.3.0)
      rails-i18n
      rainbow (>= 2.2.2, < 4.0)
      terminal-table (>= 1.5.1)
    ice_nine (0.11.2)
    initialjs-rails (0.2.0.5)
      railties (>= 3.1, < 6.0)
    invisible_captcha (0.10.0)
      rails (>= 3.2.0)
    jaro_winkler (1.5.3)
    jquery-fileupload-rails (0.4.7)
      actionpack (>= 3.1)
      railties (>= 3.1)
      sass (>= 3.2)
    jquery-rails (4.3.3)
      rails-dom-testing (>= 1, < 3)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    jquery-ui-rails (6.0.1)
      railties (>= 3.2.16)
    json (2.1.0)
    jwt (1.5.6)
    kaminari (1.1.1)
      activesupport (>= 4.1.0)
      kaminari-actionview (= 1.1.1)
      kaminari-activerecord (= 1.1.1)
      kaminari-core (= 1.1.1)
    kaminari-actionview (1.1.1)
      actionview
      kaminari-core (= 1.1.1)
    kaminari-activerecord (1.1.1)
      activerecord
      kaminari-core (= 1.1.1)
    kaminari-core (1.1.1)
    knapsack_pro (1.15.0)
      rake
    kramdown (1.17.0)
    launchy (2.4.3)
      addressable (~> 2.3)
    letter_opener (1.6.0)
      launchy (~> 2.2)
    letter_opener_web (1.3.4)
      actionmailer (>= 3.2)
      letter_opener (~> 1.0)
      railties (>= 3.2)
    loofah (2.4.0)
      crass (~> 1.0.2)
      nokogiri (>= 1.5.9)
    mail (2.7.1)
      mini_mime (>= 0.1.1)
    mdl (0.5.0)
      kramdown (~> 1.12, >= 1.12.0)
      mixlib-cli (~> 1.7, >= 1.7.0)
      mixlib-config (~> 2.2, >= 2.2.1)
    method_source (0.9.2)
    mime-types (3.1)
      mime-types-data (~> 3.2015)
    mime-types-data (3.2016.0521)
    mimemagic (0.3.2)
    mini_mime (1.0.2)
    mini_portile2 (2.4.0)
    minitest (5.14.0)
    mixlib-cli (1.7.0)
    mixlib-config (2.2.13)
      tomlrb
    multi_json (1.13.1)
    multi_xml (0.6.0)
    multipart-post (2.0.0)
    net-scp (1.2.1)
      net-ssh (>= 2.6.5)
    net-ssh (5.0.2)
    newrelic_rpm (4.1.0.333)
    nio4r (2.5.2)
    nokogiri (1.10.8)
      mini_portile2 (~> 2.4.0)
    nori (2.6.0)
    oauth (0.5.4)
    oauth2 (1.4.0)
      faraday (>= 0.8, < 0.13)
      jwt (~> 1.0)
      multi_json (~> 1.3)
      multi_xml (~> 0.5)
      rack (>= 1.2, < 3)
    octokit (4.14.0)
      sawyer (~> 0.8.0, >= 0.5.3)
    omniauth (1.9.0)
      hashie (>= 3.4.6, < 3.7.0)
      rack (>= 1.6.2, < 3)
    omniauth-facebook (4.0.0)
      omniauth-oauth2 (~> 1.2)
    omniauth-google-oauth2 (0.4.1)
      jwt (~> 1.5.2)
      multi_json (~> 1.3)
      omniauth (>= 1.1.1)
      omniauth-oauth2 (>= 1.3.1)
    omniauth-oauth (1.1.0)
      oauth
      omniauth (~> 1.0)
    omniauth-oauth2 (1.5.0)
      oauth2 (~> 1.1)
      omniauth (~> 1.2)
    omniauth-rails_csrf_protection (0.1.2)
      actionpack (>= 4.2)
      omniauth (>= 1.3.1)
    omniauth-twitter (1.4.0)
      omniauth-oauth (~> 1.1)
      rack
    orm_adapter (0.5.0)
    paperclip (5.2.1)
      activemodel (>= 4.2.0)
      activesupport (>= 4.2.0)
      cocaine (~> 0.5.5)
      mime-types
      mimemagic (~> 0.3.0)
    parallel (1.17.0)
    paranoia (2.4.2)
      activerecord (>= 4.0, < 6.1)
    parser (2.6.5.0)
      ast (~> 2.4.0)
    pg (0.21.0)
    pg_search (2.0.1)
      activerecord (>= 4.2)
      activesupport (>= 4.2)
      arel (>= 6)
    public_suffix (4.0.1)
    puma (4.3.3)
      nio4r (~> 2.0)
    rack (2.1.1)
    rack-accept (0.4.5)
      rack (>= 0.4)
    rack-attack (5.0.1)
      rack
    rack-proxy (0.6.5)
      rack
    rack-test (0.6.3)
      rack (>= 1.0)
    rails (5.0.7.2)
      actioncable (= 5.0.7.2)
      actionmailer (= 5.0.7.2)
      actionpack (= 5.0.7.2)
      actionview (= 5.0.7.2)
      activejob (= 5.0.7.2)
      activemodel (= 5.0.7.2)
      activerecord (= 5.0.7.2)
      activesupport (= 5.0.7.2)
      bundler (>= 1.3.0)
      railties (= 5.0.7.2)
      sprockets-rails (>= 2.0.0)
    rails-assets-leaflet (1.2.0)
    rails-assets-markdown-it (8.2.2)
    rails-dom-testing (2.0.3)
      activesupport (>= 4.2.0)
      nokogiri (>= 1.6)
    rails-html-sanitizer (1.3.0)
      loofah (~> 2.3)
    rails-i18n (5.1.3)
      i18n (>= 0.7, < 2)
      railties (>= 5.0, < 6)
    railties (5.0.7.2)
      actionpack (= 5.0.7.2)
      activesupport (= 5.0.7.2)
      method_source
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rainbow (3.0.0)
    rake (12.3.3)
    recipient_interceptor (0.2.0)
      mail
    redcarpet (3.4.0)
    referer-parser (0.3.0)
    request_store (1.4.0)
      rack (>= 1.4)
    responders (2.4.1)
      actionpack (>= 4.2.0, < 6.0)
      railties (>= 4.2.0, < 6.0)
    retriable (3.1.2)
    rinku (2.0.4)
    rollbar (2.18.0)
      multi_json
    rspec-core (3.8.0)
      rspec-support (~> 3.8.0)
    rspec-expectations (3.8.2)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.8.0)
    rspec-mocks (3.8.0)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.8.0)
    rspec-rails (3.8.2)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec-core (~> 3.8.0)
      rspec-expectations (~> 3.8.0)
      rspec-mocks (~> 3.8.0)
      rspec-support (~> 3.8.0)
    rspec-support (3.8.0)
    rubocop (0.75.0)
      jaro_winkler (~> 1.5.1)
      parallel (~> 1.10)
      parser (>= 2.6)
      rainbow (>= 2.2.2, < 4.0)
      ruby-progressbar (~> 1.7)
      unicode-display_width (>= 1.4.0, < 1.7)
    rubocop-performance (1.4.1)
      rubocop (>= 0.71.0)
    rubocop-rails (2.3.2)
      rack (>= 1.1)
      rubocop (>= 0.72.0)
    rubocop-rspec (1.35.0)
      rubocop (>= 0.60.0)
    ruby-progressbar (1.10.1)
    rubyzip (1.3.0)
    rvm1-capistrano3 (1.4.0)
      capistrano (~> 3.0)
      sshkit (>= 1.2)
    safely_block (0.2.0)
      errbase
    sass (3.4.25)
    sassc (2.1.0.pre3)
      ffi (~> 1.9)
    sassc-rails (2.1.2)
      railties (>= 4.0.0)
      sassc (>= 2.0)
      sprockets (> 3.0)
      sprockets-rails
      tilt
    savon (2.12.0)
      akami (~> 1.2)
      builder (>= 2.1.2)
      gyoku (~> 1.2)
      httpi (~> 2.3)
      nokogiri (>= 1.8.1)
      nori (~> 2.4)
      wasabi (~> 3.4)
    sawyer (0.8.2)
      addressable (>= 2.3.5)
      faraday (> 0.8, < 2.0)
    scss_lint (0.55.0)
      rake (>= 0.9, < 13)
      sass (~> 3.4.20)
    selenium-webdriver (3.141.0)
      childprocess (~> 0.5)
      rubyzip (~> 1.2, >= 1.2.2)
    simplecov (0.16.1)
      docile (~> 1.1)
      json (>= 1.8, < 3)
      simplecov-html (~> 0.10.0)
    simplecov-html (0.10.2)
    sitemap_generator (6.0.2)
      builder (~> 3.0)
    smart_properties (1.13.1)
    social-share-button (1.1.0)
      coffee-rails
    socksify (1.7.1)
    spring (2.0.2)
      activesupport (>= 4.2)
    spring-commands-rspec (1.0.4)
      spring (>= 0.9.1)
    sprockets (3.7.2)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    sprockets-es6 (0.9.2)
      babel-source (>= 5.8.11)
      babel-transpiler
      sprockets (>= 3.0.0)
    sprockets-rails (3.2.1)
      actionpack (>= 4.0)
      activesupport (>= 4.0)
      sprockets (>= 3.0.0)
    sshkit (1.17.0)
      net-scp (>= 1.1.2)
      net-ssh (>= 2.8.0)
    term-ansicolor (1.6.0)
      tins (~> 1.0)
    terminal-table (1.8.0)
      unicode-display_width (~> 1.1, >= 1.1.1)
    terrapin (0.6.0)
      climate_control (>= 0.0.3, < 1.0)
    thor (0.19.4)
    thread_safe (0.3.6)
    tilt (2.0.8)
    tins (1.16.3)
    tomlrb (1.2.7)
    translator-text (0.1.0)
      dry-struct (~> 0.5.0)
      httparty (~> 0.15)
    turbolinks (2.5.4)
      coffee-rails
    turnout (2.4.1)
      i18n (~> 0.7)
      rack (>= 1.3, < 3)
      rack-accept (~> 0.4)
      tilt (>= 1.4, < 3)
    tzinfo (1.2.6)
      thread_safe (~> 0.1)
    uglifier (4.1.19)
      execjs (>= 0.3.0, < 3)
    unicode-display_width (1.6.0)
    uniform_notifier (1.11.0)
    user_agent_parser (2.6.0)
    uuidtools (2.1.5)
    warden (1.2.8)
      rack (>= 2.0.6)
    wasabi (3.5.0)
      httpi (~> 2.0)
      nokogiri (>= 1.4.2)
    web-console (3.3.0)
      activemodel (>= 4.2)
      debug_inspector
      railties (>= 4.2)
    websocket-driver (0.6.5)
      websocket-extensions (>= 0.1.0)
    websocket-extensions (0.1.3)
    whenever (0.10.0)
      chronic (>= 0.6.3)
    wicked_pdf (1.1.0)
    wkhtmltopdf-binary (0.12.4)
    xpath (3.0.0)
      nokogiri (~> 1.8)

PLATFORMS
  ruby

DEPENDENCIES
  acts-as-taggable-on (~> 5.0.0)
  acts_as_votable (~> 0.11.1)
  ahoy_matey (~> 1.6.0)
  ancestry (~> 3.0.7)
  audited (~> 4.9.0)
  autoprefixer-rails (~> 8.2.0)
  bullet (~> 5.7.0)
  byebug (~> 10.0.0)
  cancancan (~> 2.3.0)
  capistrano (~> 3.10.1)
  capistrano-bundler (~> 1.2)
  capistrano-rails (~> 1.4.0)
  capistrano3-delayed-job (~> 1.7.3)
  capistrano3-puma (~> 4.0.0)
  capybara (~> 2.17.0)
  capybara-webmock (~> 0.5.3)
  ckeditor (~> 4.3.0)
  cocoon (~> 1.2.9)
  coveralls (~> 0.8.22)
  daemons (~> 1.2.4)
  dalli (~> 2.7.6)
  database_cleaner (~> 1.7.0)
  delayed_job_active_record (~> 4.1.3)
  devise (~> 4.7.1)
  devise-async (~> 1.0.0)
  devise_security_extension!
  email_spec (~> 2.2.0)
  erb_lint
  factory_bot_rails (~> 4.8.2)
  faker (~> 1.8.7)
  font-awesome-sass (~> 5.8.1)
  foundation-rails (~> 6.6.1.0)
  foundation_rails_helper (~> 3.0.0)
  github_changelog_generator (~> 1.15.0)
  globalize (~> 5.2.0)
  globalize-accessors (~> 0.2.1)
  graphiql-rails (~> 1.4.1)
  graphql (~> 1.7.8)
  groupdate (~> 3.2.0)
  i18n-tasks (~> 0.9.29)
  initialjs-rails (~> 0.2.0.5)
  invisible_captcha (~> 0.10.0)
  jquery-fileupload-rails
  jquery-rails (~> 4.3.3)
  jquery-ui-rails (~> 6.0.1)
  kaminari (~> 1.1.1)
  knapsack_pro (~> 1.15.0)
  launchy (~> 2.4.3)
  letter_opener_web (~> 1.3.4)
  mdl (~> 0.5.0)
  newrelic_rpm (~> 4.1.0.333)
  omniauth (~> 1.9.0)
  omniauth-facebook (~> 4.0.0)
  omniauth-google-oauth2 (~> 0.4.0)
  omniauth-rails_csrf_protection (~> 0.1.2)
  omniauth-twitter (~> 1.4.0)
  paperclip (~> 5.2.1)
  paranoia (~> 2.4.2)
  pg (~> 0.21.0)
  pg_search (~> 2.0.1)
  puma (~> 4.3.3)
  rails (= 5.0.7.2)
  rails-assets-leaflet!
  rails-assets-markdown-it (~> 8.2.1)!
  recipient_interceptor (~> 0.2.0)
  redcarpet (~> 3.4.0)
  responders (~> 2.4.0)
  rinku (~> 2.0.2)
  rollbar (~> 2.18.0)
  rspec-rails (~> 3.8)
  rubocop (~> 0.75.0)
  rubocop-performance (~> 1.4.1)
  rubocop-rails (~> 2.3.2)
  rubocop-rspec (~> 1.35.0)
  rvm1-capistrano3 (~> 1.4.0)
  sassc-rails (~> 2.1.2)
  savon (~> 2.12.0)
  scss_lint (~> 0.55.0)
  selenium-webdriver (~> 3.141)
  sitemap_generator (~> 6.0.2)
  social-share-button (~> 1.1)
  spring (~> 2.0.1)
  spring-commands-rspec (~> 1.0.4)
  sprockets (~> 3.7.2)
  translator-text (~> 0.1.0)
  turbolinks (~> 2.5.3)
  turnout (~> 2.4.0)
  uglifier (~> 4.1.2)
  web-console (~> 3.3.0)
  whenever (~> 0.10.0)
  wicked_pdf (~> 1.1.0)
  wkhtmltopdf-binary (~> 0.12.4)

BUNDLED WITH
   2.1.4

Here is my Dockerfile

# Use Ruby 2.3.8 as base image
FROM ruby:2.4.9

ENV DEBIAN_FRONTEND noninteractive

# Install essential Linux packages
RUN apt-get update -qq
RUN apt-get install -y build-essential libpq-dev postgresql-client nodejs imagemagick sudo libxss1 libappindicator1 libindicator7 unzip memcached

# Files created inside the container repect the ownership
RUN adduser --shell /bin/bash --disabled-password --gecos "" consul \
  && adduser consul sudo \
  && echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

RUN echo 'Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bundle/bin:/var/lib/gems/1.8/bin"' > /etc/sudoers.d/secure_path
RUN chmod 0440 /etc/sudoers.d/secure_path

COPY scripts/entrypoint.sh /usr/local/bin/entrypoint.sh

# Define where our application will live inside the image
ENV RAILS_ROOT /opt/consul

# Create application home. App server will need the pids dir so just create everything in one shot
RUN mkdir -p $RAILS_ROOT/tmp/pids

# Set our working directory inside the image
WORKDIR $RAILS_ROOT

# Use the Gemfiles as Docker cache markers. Always bundle before copying app src.
# (the src likely changed and we don't want to invalidate Docker's cache too early)
# http://ilikestuffblog.com/2014/01/06/how-to-skip-bundle-install-when-deploying-a-rails-app-to-docker/
COPY Gemfile Gemfile

COPY Gemfile.lock Gemfile.lock

COPY Gemfile_custom Gemfile_custom

# Prevent bundler warnings; ensure that the bundler version executed is >= that which created Gemfile.lock
RUN gem install bundler

RUN gem update --system
RUN gem update bundler

RUN gem install rake

# Finish establishing our Ruby environment
RUN bundle install --full-index

# Install Chromium and ChromeDriver for E2E integration tests
RUN apt-get update -qq && apt-get install -y chromium
RUN wget -N http://chromedriver.storage.googleapis.com/2.38/chromedriver_linux64.zip
RUN unzip chromedriver_linux64.zip
RUN chmod +x chromedriver
RUN mv -f chromedriver /usr/local/share/chromedriver
RUN ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
RUN ln -s /usr/local/share/chromedriver /usr/bin/chromedriver

# Copy the Rails application into place
COPY . .

# Add rake to path
#RUN ln -s /var/lib/gems/1.8/bin/rake /usr/bin/rake

# Define the script we want run once the container boots
# Use the "exec" form of CMD so our script shuts down gracefully on SIGTERM (i.e. `docker stop`)
# CMD [ "config/containers/app_cmd.sh" ]
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]

Here is my docker-compose.yml

version: "3.7"
services:
  # service configuration for our database
  database:
    image: postgres:12.1
    environment:
      POSTGRES_USER: consul
      POSTGRES_PASSWORD: consul_db_password
    ports:
      - '5432:5432'
    # persist the database between containers by storing it in a volume
    volumes:
      - postgres:/var/lib/postgresql/data

  # service configuration for our dockerized Rails app
  web:
    image: consul:0.0.9
    entrypoint: /usr/local/bin/entrypoint.sh
    command: bundle exec rails s -p 3000 -b "0.0.0.0"
    working_dir: /opt/consul

    # rely on the RAILS_ENV value of the host machine
    # environment:
    #RAILS_ENV: $RAILS_ENV
    depends_on:
      - database

    ports:
      - "3000:3000"
    volumes:
      - .:/opt/consul:delegated
      - bundle:/usr/local/bundle:delegated
      - "$SSH_AUTH_SOCK:/tmp/agent.sock"
    environment:
      - SSH_AUTH_SOCK=/tmp/agent.sock

volumes:
  postgres: {}
  bundle: {}

And here is my entrypoin.sh

#!/bin/sh -x

USER_UID=$(stat -c %u /opt/consul/Gemfile)
USER_GID=$(stat -c %g /opt/consul/Gemfile)

export USER_UID
export USER_GID

usermod -u "$USER_UID" consul 2> /dev/null
groupmod -g "$USER_GID" consul 2> /dev/null
usermod -g "$USER_GID" consul 2> /dev/null

#chown -R -h "$USER_UID" "$BUNDLE_PATH"
#chgrp -R -h "$USER_GID" "$BUNDLE_PATH"

rm -rf /opt/consul/tmp/pids/server.pid

set -e

bundle exec rake db:create
bundle exec rake db:migrate
bundle exec rake db:setup

/usr/bin/sudo -EH -u consul "$@"
-- Leonardo Benicio
docker
kubernetes
rake
ruby
ruby-on-rails

0 Answers