0

下記のサイトを参考にdocker build .をしたいのですがうまくいきません
https://engineering.adwerx.com/rails-on-kubernetes-8cd4940eacbe

最初は
app.conf
config.ru
Dockerfile
env.conf
Gemfile
Gemfile.lock
Rakefile
を作り、docker build .を実行したところ下記エラーが出ました。

rake aborted! Do not know how to build task 'assets: precompile'
 (See full trace by running task with - trace) The command '/ bin / sh -c bundle  exec rake ass

ets: precompile' returned a non-zero code: 1 I got an error saying.

次に
https://github.com/jbielick/rails-kube-demogit cloneしたのですが
下記エラーがでました。

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/usr/local/rvm/gems/ruby-2.3.8/gems/puma-3.6.0/ext/puma_http11
/usr/local/rvm/rubies/ruby-2.3.8/bin/ruby -r ./siteconf20190109-5-1ymcdr3.rb
extconf.rb
checking for BIO_read() in -lcrypto... yes
checking for SSL_CTX_new() in -lssl... yes
checking for openssl/bio.h... yes
creating Makefile
current directory:
/usr/local/rvm/gems/ruby-2.3.8/gems/puma-3.6.0/ext/puma_http11
make "DESTDIR=" clean
current directory:
/usr/local/rvm/gems/ruby-2.3.8/gems/puma-3.6.0/ext/puma_http11
make "DESTDIR="
compiling http11_parser.c
In file included from ext/puma_http11/http11_parser.rl:7:0:
ext/puma_http11/http11_parser.rl: In function ‘puma_parser_execute’:
ext/puma_http11/http11_parser.rl:111:17: warning: comparison between signed and
unsigned integer expressions [-Wsign-compare]
ext/puma_http11/http11_parser.rl:37:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.rl:39:1: note: here
ext/puma_http11/http11_parser.rl:52:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.rl:54:1: note: here
ext/puma_http11/http11_parser.rl:37:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.rl:39:1: note: here
ext/puma_http11/http11_parser.rl:55:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.rl:57:1: note: here
ext/puma_http11/http11_parser.rl:37:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.rl:39:1: note: here
ext/puma_http11/http11_parser.c:244:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:246:1: note: here
ext/puma_http11/http11_parser.c:251:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:253:1: note: here
ext/puma_http11/http11_parser.c:258:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:260:1: note: here
ext/puma_http11/http11_parser.c:265:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:267:1: note: here
ext/puma_http11/http11_parser.c:272:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:274:1: note: here
ext/puma_http11/http11_parser.c:281:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:283:1: note: here
ext/puma_http11/http11_parser.c:288:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:290:1: note: here
ext/puma_http11/http11_parser.rl:49:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.rl:51:1: note: here
ext/puma_http11/http11_parser.c:325:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:327:1: note: here
ext/puma_http11/http11_parser.c:353:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:355:1: note: here
ext/puma_http11/http11_parser.rl:41:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.rl:43:1: note: here
ext/puma_http11/http11_parser.rl:46:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.rl:48:1: note: here
ext/puma_http11/http11_parser.rl:46:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.rl:48:1: note: here
ext/puma_http11/http11_parser.rl:55:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.rl:57:1: note: here
ext/puma_http11/http11_parser.rl:37:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.rl:39:1: note: here
ext/puma_http11/http11_parser.rl:37:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.rl:39:1: note: here
ext/puma_http11/http11_parser.rl:37:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.rl:39:1: note: here
ext/puma_http11/http11_parser.rl:37:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.rl:39:1: note: here
ext/puma_http11/http11_parser.rl:71:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.rl:73:1: note: here
ext/puma_http11/http11_parser.rl:71:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.rl:73:1: note: here
ext/puma_http11/http11_parser.rl:60:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.rl:62:1: note: here
ext/puma_http11/http11_parser.c:653:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:655:1: note: here
ext/puma_http11/http11_parser.c:671:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:673:1: note: here
ext/puma_http11/http11_parser.c:689:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:691:1: note: here
ext/puma_http11/http11_parser.c:707:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:709:1: note: here
ext/puma_http11/http11_parser.c:725:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:727:1: note: here
ext/puma_http11/http11_parser.c:743:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:745:1: note: here
ext/puma_http11/http11_parser.c:761:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:763:1: note: here
ext/puma_http11/http11_parser.c:779:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:781:1: note: here
ext/puma_http11/http11_parser.c:797:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:799:1: note: here
ext/puma_http11/http11_parser.c:815:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:817:1: note: here
ext/puma_http11/http11_parser.c:833:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:835:1: note: here
ext/puma_http11/http11_parser.c:851:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:853:1: note: here
ext/puma_http11/http11_parser.c:869:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:871:1: note: here
ext/puma_http11/http11_parser.c:887:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:889:1: note: here
ext/puma_http11/http11_parser.c:905:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:907:1: note: here
ext/puma_http11/http11_parser.c:923:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:925:1: note: here
ext/puma_http11/http11_parser.c:941:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:943:1: note: here
ext/puma_http11/http11_parser.c:959:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:961:1: note: here
ext/puma_http11/http11_parser.c:977:5: warning: this statement may fall through
[-Wimplicit-fallthrough=]
ext/puma_http11/http11_parser.c:979:1: note: here
compiling io_buffer.c
compiling mini_ssl.c
mini_ssl.c: In function ‘get_dh1024’:
mini_ssl.c:90:5: error: dereferencing pointer to incomplete type ‘DH {aka struct
dh_st}’
   dh->p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL);
     ^~
mini_ssl.c: In function ‘engine_init_server’:
mini_ssl.c:139:3: warning: ISO C90 forbids mixed declarations and code
[-Wdeclaration-after-statement]
   ID sym_cert = rb_intern("cert");
   ^~
mini_ssl.c:144:3: warning: ISO C90 forbids mixed declarations and code
[-Wdeclaration-after-statement]
   ID sym_ca = rb_intern("ca");
   ^~
mini_ssl.c:166:3: warning: ISO C90 forbids mixed declarations and code
[-Wdeclaration-after-statement]
   DH *dh = get_dh1024();
   ^~
mini_ssl.c:170:3: warning: ISO C90 forbids mixed declarations and code
[-Wdeclaration-after-statement]
   EC_KEY *ecdh = EC_KEY_new_by_curve_name(NID_secp521r1);
   ^~~~~~
mini_ssl.c: In function ‘engine_init_client’:
mini_ssl.c:197:3: warning: ‘DTLSv1_method’ is deprecated
[-Wdeprecated-declarations]
   conn->ctx = SSL_CTX_new(DTLSv1_method());
   ^~~~
In file included from /usr/include/openssl/ct.h:13:0,
                 from /usr/include/openssl/ssl.h:61,
                 from mini_ssl.c:15:
/usr/include/openssl/ssl.h:1642:1: note: declared here
 DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_method(void)) /* DTLSv1.0 */
 ^
Makefile:238: recipe for target 'mini_ssl.o' failed
make: *** [mini_ssl.o] Error 1
make failed, exit code 2
Gem files will remain installed in
/usr/local/rvm/gems/ruby-2.3.8/gems/puma-3.6.0 for inspection.
Results logged to
/usr/local/rvm/gems/ruby-2.3.8/extensions/x86_64-linux/2.3.0/puma-3.6.0/gem_make.out
An error occurred while installing puma (3.6.0), and Bundler cannot continue.
Make sure that `gem install puma -v '3.6.0' --source 'https://rubygems.org/'`
succeeds before bundling.
In Gemfile:
  puma
The command '/bin/sh -c bundle install' returned a non-zero code: 5
0

1 件の回答 1

3

最終的に以下のようにするとbuildできました。

ref: https://github.com/puma/puma/issues/1136

  1. Dockerfile以下のように修正

    23行目: curl libssl-dev \ -> curl libssl1.0-dev \

    Dockerfile

    FROM phusion/passenger-ruby23
    
    # set some rails env vars
    ENV RAILS_ENV production
    ENV BUNDLE_PATH /bundle
    
    # set the app directory var
    ENV APP_HOME /home/app
    WORKDIR $APP_HOME
    
    # Enable nginx/passenger
    RUN rm -f /etc/service/nginx/down
    
    # Disable SSH
    # Some discussion on this: https://news.ycombinator.com/item?id=7950326
    RUN rm -rf /etc/service/sshd /etc/my_init.d/00_regen_ssh_host_keys.sh
    
    RUN apt-get update -qq
    
    # Install apt dependencies
    RUN apt-get install -y --no-install-recommends \
      build-essential \
      curl libssl1.0-dev \
      git \
      unzip \
      zlib1g-dev \
      libxslt-dev \
      mysql-client \
      sqlite3
    
    # install bundler
    RUN gem install bundler
    
    # Separate task from `add . .` as it will be
    # Skipped if gemfile.lock hasn't changed
    COPY Gemfile* ./
    
    # Install gems to /bundle
    RUN bundle install
    
    # place the nginx / passenger config
    RUN rm /etc/nginx/sites-enabled/default
    ADD nginx/env.conf /etc/nginx/main.d/env.conf
    ADD nginx/app.conf /etc/nginx/sites-enabled/app.conf
    
    ADD . .
    
    # compile assets!
    RUN bundle exec rake assets:precompile
    
    EXPOSE 3000
    
    CMD ["/sbin/my_init"]
    
  2. Gemfile.lockを削除

  3. Gemfile以下のように修正
    48行目: gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] -> gem 'tzinfo-data'

    source 'https://rubygems.org'
    
    
    # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
    gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
    # Use mysql as the database for Active Record
    gem 'mysql2', '>= 0.3.18', '< 0.5'
    # Use Puma as the app server
    gem 'puma', '~> 3.0'
    # Use SCSS for stylesheets
    gem 'sass-rails', '~> 5.0'
    # Use Uglifier as compressor for JavaScript assets
    gem 'uglifier', '>= 1.3.0'
    # Use CoffeeScript for .coffee assets and views
    gem 'coffee-rails', '~> 4.2'
    # See https://github.com/rails/execjs#readme for more supported runtimes
    # gem 'therubyracer', platforms: :ruby
    
    # Use jquery as the JavaScript library
    gem 'jquery-rails'
    # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
    gem 'turbolinks', '~> 5'
    # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
    gem 'jbuilder', '~> 2.5'
    # Use Redis adapter to run Action Cable in production
    # gem 'redis', '~> 3.0'
    # Use ActiveModel has_secure_password
    # gem 'bcrypt', '~> 3.1.7'
    
    # Use Capistrano for deployment
    # gem 'capistrano-rails', group: :development
    
    group :development, :test do
      # Call 'byebug' anywhere in the code to stop execution and get a debugger console
      gem 'byebug', platform: :mri
    end
    
    group :development do
      # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
      gem 'web-console'
      gem 'listen', '~> 3.0.5'
      # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
      gem 'spring'
      gem 'spring-watcher-listen', '~> 2.0.0'
    end
    
    # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
    gem 'tzinfo-data'
    

2年前のもので依存パッケージのverが変わってしまい、エラーが起きていましたね…
2年となるともう古いので、なるべく新し目のチュートリアルをお勧めします。

1
  • 1
    本当にありがとうございます。 試してみたいと思います。 新し目のチュートリアルも探してみます
    – user19514
    Commented 2019年1月10日 11:20

この質問に回答するには、ログインする必要があります。

求めていた回答ではありませんか? のタグが付いた他の質問を参照する。