From 9d36e5e1a6057f6d9c6396e68c3be9771202be7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= <69143962+pmalek-sumo@users.noreply.github.com> Date: Thu, 24 Sep 2020 14:46:59 +0200 Subject: [PATCH] Refactor build Dockerfile (#949) --- deploy/docker/Dockerfile | 97 +++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 45 deletions(-) diff --git a/deploy/docker/Dockerfile b/deploy/docker/Dockerfile index 4a21f747f8..8692b87f19 100644 --- a/deploy/docker/Dockerfile +++ b/deploy/docker/Dockerfile @@ -3,57 +3,63 @@ FROM fluent/fluentd:v1.11.1-debian-1.0 AS builder # Use root account to use apt USER root -# Build dependencies -RUN buildDeps="sudo make gcc g++ libc-dev ruby-dev libsnappy-dev" \ - && apt-get update \ - && apt-get install -y --no-install-recommends $buildDeps - -COPY gems/fluent-plugin*.gem ./ +# Dependencies +RUN apt-get update \ + && apt-get install --yes --no-install-recommends \ + curl \ + g++ \ + gcc \ + libc-dev \ + libsnappy-dev \ + make \ + ruby-dev \ + sudo \ + unzip # Fluentd plugin dependencies -RUN gem install concurrent-ruby -v 1.1.5 \ - && gem install google-protobuf -v 3.9.2 \ - && gem install kubeclient -v 4.9.1 \ - && gem install lru_redux -v 1.1.0 \ - && gem install snappy -v 0.0.17 +RUN gem install \ + concurrent-ruby:1.1.5 \ + google-protobuf:3.9.2 \ + kubeclient:4.9.1 \ + lru_redux:1.1.0 \ + snappy:0.0.17 # FluentD plugins to allow customers to forward data if needed to various cloud providers -RUN gem install fluent-plugin-s3 - # TODO: Support additional cloud providers - # && gem install fluent-plugin-google-cloud \ - # && gem install fluent-plugin-azure-storage-append-blob +RUN gem install \ + fluent-plugin-s3 + # TODO: Support additional cloud providers + # && gem install fluent-plugin-google-cloud \ + # && gem install fluent-plugin-azure-storage-append-blob # FluentD plugins from RubyGems -RUN gem install fluent-plugin-systemd -v 1.0.2 \ - && gem install fluent-plugin-record-modifier -v 2.0.1 \ - && gem install fluent-plugin-kubernetes_metadata_filter -v 2.4.1 \ - && gem install fluent-plugin-sumologic_output -v 1.7.1 \ - && gem install fluent-plugin-concat -v 2.4.0 \ - && gem install fluent-plugin-rewrite-tag-filter -v 2.2.0 \ - && gem install fluent-plugin-prometheus -v 1.6.1 - -# FluentD plugins from this repository -RUN gem install --local fluent-plugin-prometheus-format \ - && gem install --local fluent-plugin-kubernetes-sumologic \ - && gem install --local fluent-plugin-enhance-k8s-metadata \ - && gem install --local fluent-plugin-datapoint \ - && gem install --local fluent-plugin-protobuf \ - && gem install --local fluent-plugin-events - -# Run dependencies -RUN apt-get update \ - && apt-get install -y curl \ - && apt-get install -y unzip +RUN gem install \ + fluent-plugin-systemd:1.0.2 \ + fluent-plugin-record-modifier:2.0.1 \ + fluent-plugin-kubernetes_metadata_filter:2.4.1 \ + fluent-plugin-sumologic_output:1.7.1 \ + fluent-plugin-concat:2.4.0 \ + fluent-plugin-rewrite-tag-filter:2.2.0 \ + fluent-plugin-prometheus:1.6.1 # Install Terraform ENV TERRAFORM_VERSION 0.12.26 -RUN mkdir /tmp/terraform && \ - curl https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip -o /tmp/terraform/terraform.zip && \ - cd /tmp/terraform && \ - unzip terraform.zip && \ - mv terraform /bin/terraform && \ - chmod +x /bin/terraform && \ - rm -rf /tmp/terraform +RUN mkdir /tmp/terraform \ + && curl https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip -o /tmp/terraform/terraform.zip \ + && cd /tmp/terraform \ + && unzip terraform.zip \ + && mv terraform /bin/terraform \ + && chmod +x /bin/terraform \ + && rm -rf /tmp/terraform + +# FluentD plugins from this repository +COPY gems/fluent-plugin*.gem ./ +RUN gem install \ + --local fluent-plugin-prometheus-format \ + --local fluent-plugin-kubernetes-sumologic \ + --local fluent-plugin-enhance-k8s-metadata \ + --local fluent-plugin-datapoint \ + --local fluent-plugin-protobuf \ + --local fluent-plugin-events # Start with fresh image FROM fluent/fluentd:v1.11.1-debian-1.0 @@ -61,11 +67,12 @@ FROM fluent/fluentd:v1.11.1-debian-1.0 USER root RUN apt-get update \ - && apt-get install -y --no-install-recommends libsnappy-dev + && apt-get install --yes --no-install-recommends \ + libsnappy-dev # Create directory for terraform configuration -RUN mkdir -p /terraform && \ - chown -R fluent /terraform +RUN mkdir -p /terraform \ + && chown -R fluent /terraform COPY --from=builder /bin/terraform /bin/terraform COPY --from=builder /usr/local/bundle /usr/local/bundle