Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use build image and copy for loki #29

Merged
merged 1 commit into from
Apr 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions loki/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
# https://github.com/hassio-addons/addon-base/releases
ARG BUILD_FROM=ghcr.io/hassio-addons/base/amd64:9.1.5

# hadolint ignore=DL3006
FROM $BUILD_FROM

# https://github.com/grafana/loki/releases
FROM alpine:3.13.4 as build
ENV LOKI_VERSION 2.2.0

# Add Loki
RUN set -eux; \
apk update; \
apk add --no-cache --virtual .build-deps \
unzip=6.0-r8 \
curl=7.74.0-r1 \
; \
APKARCH="$(apk --print-arch)"; \
case "$APKARCH" in \
x86_64) BINARCH='amd64' ;; \
armhf) BINARCH='arm' ;; \
armv7) BINARCH='arm' ;; \
aarch64) BINARCH='arm64' ;; \
*) echo >&2 "error: unsupported architecture ($APKARCH)"; exit 1 ;; \
x86_64) BINARCH='amd64' ;; \
armhf) BINARCH='arm' ;; \
armv7) BINARCH='arm' ;; \
aarch64) BINARCH='arm64' ;; \
*) echo >&2 "error: unsupported architecture ($APKARCH)"; exit 1 ;; \
esac; \
\
curl -J -L -o /tmp/loki.zip "https://github.com/grafana/loki/releases/download/v${LOKI_VERSION}/loki-linux-${BINARCH}.zip"; \
unzip /tmp/loki.zip -d /usr/bin; \
mv /usr/bin/loki-linux-${BINARCH} /usr/bin/loki; \
chmod a+x /usr/bin/loki; \
loki -version; \
rm -f /tmp/loki.zip;
chmod a+x /usr/bin/loki;


# hadolint ignore=DL3006
FROM $BUILD_FROM

# add Nginx
# hadolint ignore=DL3009
Expand All @@ -46,12 +49,16 @@ RUN set -eux; \
# See https://github.com/grafana/loki/issues/1928
RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf

COPY rootfs /
# Add Loki
COPY --from=build /usr/bin/loki /usr/bin/loki

WORKDIR /data/loki
RUN set -eux; \
mkdir -p /data/loki; \
loki --version; \
addgroup -S abc; \
adduser -u 12345 -h /data/loki -D -S abc -G abc;
WORKDIR /data/loki

COPY rootfs /

# Build arguments
ARG BUILD_ARCH
Expand Down