yokawasa/fluent-plugin-azure-loganalytics

Trying to add plugin within the docker container

webash opened this issue · 1 comments

webash commented

Per this fluentd documentation, I'm trying to build the official container with your plugin added.

# fluentd/Dockerfile
# inspired by: https://docs.fluentd.org/container-deployment/docker-compose

FROM arm64v8/fluentd:v1.16.0-1.0
USER root
RUN apk --no-cache add \ 
	gcc \
	libffi-dev \
	make \
	ruby-dev && \
	gem install --no-document rake fluent-plugin-elasticsearch fluent-plugin-azure-loganalytics && \
	apk del ruby-dev
USER fluent

However, when I do, I get the following errors. I don't know anything about ruby and find it very difficult to find any clarity about it online despite being someone with programming experience (but not an active programmer).

Any chance you can help?

Here's the relevant log:

#0 20.88 Successfully installed rake-13.0.6
#0 20.88 Successfully installed faraday-net_http-3.0.2
#0 20.88 Successfully installed faraday-2.7.4
#0 20.88 Successfully installed excon-0.99.0
#0 20.88 Successfully installed faraday-excon-2.1.0
#0 20.88 Successfully installed multi_json-1.15.0
#0 20.88 Successfully installed elastic-transport-8.2.1
#0 20.88 Successfully installed elasticsearch-api-8.7.0
#0 20.88 Successfully installed elasticsearch-8.7.0
#0 20.88 Successfully installed fluent-plugin-elasticsearch-5.3.0
#0 20.88 Successfully installed netrc-0.11.0
#0 20.88 Successfully installed mime-types-data-3.2023.0218.1
#0 20.88 Successfully installed mime-types-3.4.1
#0 20.88 Building native extensions. This could take a while...
#0 21.93 ERROR:  Error installing fluent-plugin-azure-loganalytics:
#0 21.93        ERROR: Failed to build gem native extension.
#0 21.93
#0 21.93     current directory: /usr/lib/ruby/gems/3.1.0/gems/unf_ext-0.0.8.2/ext/unf_ext
#0 21.93 /usr/bin/ruby -I /usr/lib/ruby/3.1.0 extconf.rb
#0 21.93 checking for -lstdc++... *** extconf.rb failed ***
#0 21.93 Could not create Makefile due to some reason, probably lack of necessary
#0 21.93 libraries and/or headers.  Check the mkmf.log file for more details.  You may
#0 21.93 need configuration options.
#0 21.93
#0 21.93 Provided configuration options:
#0 21.93        --with-opt-dir
#0 21.93        --without-opt-dir
#0 21.93        --with-opt-include
#0 21.93        --without-opt-include=${opt-dir}/include
#0 21.93        --with-opt-lib
#0 21.93        --without-opt-lib=${opt-dir}/lib
#0 21.93        --with-make-prog
#0 21.93        --without-make-prog
#0 21.93        --srcdir=.
#0 21.93        --curdir
#0 21.93        --ruby=/usr/bin/$(RUBY_BASE_NAME)
#0 21.93        --with-static-libstdc++
#0 21.93        --without-static-libstdc++
#0 21.93        --with-stdc++-dir
#0 21.93        --without-stdc++-dir
#0 21.93        --with-stdc++-include
#0 21.93        --without-stdc++-include=${stdc++-dir}/include
#0 21.93        --with-stdc++-lib
#0 21.93        --without-stdc++-lib=${stdc++-dir}/lib
#0 21.93        --with-stdc++lib
#0 21.93        --without-stdc++lib
#0 21.93 /usr/lib/ruby/3.1.0/mkmf.rb:490:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
#0 21.93 You have to install development tools first.
#0 21.93        from /usr/lib/ruby/3.1.0/mkmf.rb:583:in `try_link0'
#0 21.93        from /usr/lib/ruby/3.1.0/mkmf.rb:601:in `try_link'
#0 21.93        from /usr/lib/ruby/3.1.0/mkmf.rb:819:in `try_func'
#0 21.93        from /usr/lib/ruby/3.1.0/mkmf.rb:1062:in `block in have_library'
#0 21.93        from /usr/lib/ruby/3.1.0/mkmf.rb:989:in `block in checking_for'
#0 21.93        from /usr/lib/ruby/3.1.0/mkmf.rb:354:in `block (2 levels) in postpone'
#0 21.93        from /usr/lib/ruby/3.1.0/mkmf.rb:324:in `open'
#0 21.93        from /usr/lib/ruby/3.1.0/mkmf.rb:354:in `block in postpone'
#0 21.93        from /usr/lib/ruby/3.1.0/mkmf.rb:324:in `open'
#0 21.93        from /usr/lib/ruby/3.1.0/mkmf.rb:350:in `postpone'
#0 21.93        from /usr/lib/ruby/3.1.0/mkmf.rb:988:in `checking_for'
#0 21.93        from /usr/lib/ruby/3.1.0/mkmf.rb:1057:in `have_library'
#0 21.93        from extconf.rb:6:in `<main>'
#0 21.93
#0 21.93 To see why this extension failed to compile, please check the mkmf.log which can be found here:
#0 21.93
#0 21.93   /usr/lib/ruby/gems/3.1.0/extensions/aarch64-linux-musl/3.1.0/unf_ext-0.0.8.2/mkmf.log
#0 21.93
#0 21.93 extconf failed, exit code 1
#0 21.93
#0 21.93 Gem files will remain installed in /usr/lib/ruby/gems/3.1.0/gems/unf_ext-0.0.8.2 for inspection.
#0 21.93 Results logged to /usr/lib/ruby/gems/3.1.0/extensions/aarch64-linux-musl/3.1.0/unf_ext-0.0.8.2/gem_make.out
#0 21.96 10 gems installed
------
failed to solve: process "/bin/sh -c apk add \tgcc \tlibffi-dev \tmake \truby-dev && \tgem install --no-document rake fluent-plugin-elasticsearch fluent-plugin-azure-loganalytics && \tapk del ruby-full" did not complete successfully: exit code: 1
webash commented

Nevermind. Just after posting this I found an article about needing build-base when using an alpine-based container.

The resulting Dockerfile is this:

# fluentd/Dockerfile
# inspired by: https://docs.fluentd.org/container-deployment/docker-compose

FROM arm64v8/fluentd:v1.16.0-1.0
USER root
RUN apk --no-cache add \ 
	build-base \
	ruby-dev && \
	gem install --no-document rake fluent-plugin-elasticsearch fluent-plugin-azure-loganalytics && \
	apk del ruby-dev build-base
USER fluent