Skip to content

Commit

Permalink
Merge pull request #29 from mdegat01/use-build-image
Browse files Browse the repository at this point in the history
Use build image and copy for loki
  • Loading branch information
mdegat01 authored Apr 3, 2021
2 parents c7a54bd + 0aba985 commit 7cc104a
Showing 1 changed file with 23 additions and 16 deletions.
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

0 comments on commit 7cc104a

Please sign in to comment.