Skip to content

Commit

Permalink
feat: Add ARM support (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevehipwell authored Feb 10, 2022
1 parent 248a5e4 commit f24a898
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ jobs:
with:
file: ./Dockerfile
context: .
platforms: linux/amd64
platforms: linux/amd64,linux/arm64
push: false
3 changes: 2 additions & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ jobs:
with:
file: ./Dockerfile
context: .
platforms: linux/amd64
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}

# - name: Update repo description
# uses: peter-evans/dockerhub-description@v2
# with:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Deprecated
### Removed -->

## [v1.14.8] - 2022-02-10

### Added

- Added ARM64 support via building image from scratch.

## [v1.14.7] - 2022-02-09

### Changed
Expand Down
106 changes: 84 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
FROM fluent/fluentd:v1.14.5-1.0
FROM alpine:3.13

# Default env
ENV RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR="0.9"

# Use root account to use apk
USER root

# Add system dependencies
RUN set -eu; \
apk add --no-cache \
libcurl;

# Add custom plugins
RUN set -eu; \
apk add --no-cache --virtual .build-deps sudo build-base ruby-dev; \
sudo gem install \
RUN apk update \
&& apk add --no-cache \
ca-certificates \
libcurl \
ruby ruby-irb ruby-etc ruby-webrick \
tini \
&& apk add --no-cache --virtual .build-deps \
build-base linux-headers \
ruby-dev gnupg \
&& echo 'gem: --no-document' >> /etc/gemrc \
&& gem install oj -v 3.10.18 \
&& gem install json -v 2.4.1 \
&& gem install async-http -v 0.54.0 \
&& gem install ext_monitor -v 0.1.2 \
&& gem install fluentd -v 1.14.5 \
&& gem install bigdecimal -v 1.4.4 \
&& gem install \
elasticsearch-api:7.13.3 \
elasticsearch-transport:7.13.3 \
elasticsearch:7.13.3 \
Expand All @@ -32,13 +34,73 @@ RUN set -eu; \
fluent-plugin-rewrite-tag-filter \
fluent-plugin-route \
fluent-plugin-s3 \
fluent-plugin-sqs; \
sudo gem sources --clear-all; \
apk del .build-deps; \
rm -rf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem;
fluent-plugin-sqs \
&& apk del .build-deps \
&& rm -rf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem /usr/lib/ruby/gems/2.*/gems/fluentd-*/test

RUN addgroup -S fluent && adduser -S -G fluent fluent \
# for log storage (maybe shared with host)
&& mkdir -p /fluentd/log \
# configuration/plugins path (default: copied from .)
&& mkdir -p /fluentd/etc /fluentd/plugins \
&& chown -R fluent /fluentd && chgrp -R fluent /fluentd


# Overwrite conf
COPY fluent.conf /fluentd/etc/
COPY entrypoint.sh /bin/


ENV FLUENTD_CONF="fluent.conf"
ENV RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR="0.9"

ENV LD_PRELOAD=""
EXPOSE 24224 5140

# Set back to non-root user
USER fluent
ENTRYPOINT ["tini", "--", "/bin/entrypoint.sh"]
CMD ["fluentd"]

# FROM fluent/fluentd:v1.14.5-1.0

# # Default env
# ENV RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR="0.9"

# # Use root account to use apk
# USER root

# # Add system dependencies
# RUN set -eu; \
# apk add --no-cache \
# libcurl;

# # Add custom plugins
# RUN set -eu; \
# apk add --no-cache --virtual .build-deps build-base ruby-dev; \
# gem install \
# elasticsearch-api:7.13.3 \
# elasticsearch-transport:7.13.3 \
# elasticsearch:7.13.3 \
# fluent-plugin-aws-elasticsearch-service \
# fluent-plugin-azure-loganalytics \
# fluent-plugin-azurestorage-gen2 \
# fluent-plugin-cloudwatch-logs \
# fluent-plugin-concat \
# fluent-plugin-datadog \
# fluent-plugin-elasticsearch \
# fluent-plugin-grafana-loki \
# fluent-plugin-opensearch \
# fluent-plugin-prometheus \
# fluent-plugin-record-modifier \
# fluent-plugin-rewrite-tag-filter \
# fluent-plugin-route \
# fluent-plugin-s3 \
# fluent-plugin-sqs; \
# sudo gem sources --clear-all; \
# apk del .build-deps; \
# rm -rf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem;

# # Overwrite conf
# COPY fluent.conf /fluentd/etc/

# # Set back to non-root user
# USER fluent
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# Fluentd Aggregator

[![Docker Image Version (latest semver)](https://img.shields.io/docker/v/stevehipwell/fluentd-aggregator?sort=semver)](https://hub.docker.com/r/stevehipwell/fluentd-aggregator)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
![linux](https://img.shields.io/badge/os-linux-brightgreen)
![amd64](https://img.shields.io/badge/arch-amd64-brightgreen)
![arm64](https://img.shields.io/badge/arch-arm64-brightgreen)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

A [Fluentd](https://www.fluentd.org/) _Docker_ image to be used for log aggregation and based on the official [Fluentd Docker image](https://github.com/fluent/fluentd-docker-image).
A [Fluentd](https://www.fluentd.org/) [OCI](https://opencontainers.org/) image to be used for log aggregation and based on the official [Fluentd Docker image](https://github.com/fluent/fluentd-docker-image) rebuilt as a multi-arch `linux/amd64` & `linux/arm64` image.

## Aggregation Changes

To optimise _Fluentd_ for log aggregation the default `fluent.conf` file has been overwritten to allow logs to be forwarded and printed to stdout. Plugins have also been added to support the aggregation role.

### Versioning

The image version isn't strictly SemVer compatible as it tracks the major and minor versions of the _Fluentd_ releases it's based on and uses the patch version for both patches and features.

### Plugins

The following plugins have been added to the base image.
Expand Down
28 changes: 28 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

#source vars if file exists
DEFAULT=/etc/default/fluentd

if [ -r $DEFAULT ]; then
set -o allexport
. $DEFAULT
set +o allexport
fi

# If the user has supplied only arguments append them to `fluentd` command
if [ "${1#-}" != "$1" ]; then
set -- fluentd "$@"
fi

# If user does not supply config file or plugins, use the default
if [ "$1" = "fluentd" ]; then
if ! echo $@ | grep -e ' \-c' -e ' \-\-config' ; then
set -- "$@" --config /fluentd/etc/${FLUENTD_CONF}
fi

if ! echo $@ | grep -e ' \-p' -e ' \-\-plugin' ; then
set -- "$@" --plugin /fluentd/plugins
fi
fi

exec "$@"

0 comments on commit f24a898

Please sign in to comment.