1ARG BUILD_IMAGE=grafana/loki-build-image:0.12.0
2# Directories in this file are referenced from the root of the project not this folder
3# This file is intended to be called from the root like so:
4# docker build -t grafana/loki -f cmd/loki/Dockerfile .
5FROM golang:1.16.2-alpine as goenv
6RUN go env GOARCH > /goarch && \
7    go env GOARM > /goarm
8
9FROM --platform=linux/amd64 $BUILD_IMAGE as build
10COPY --from=goenv /goarch /goarm /
11COPY . /src/loki
12WORKDIR /src/loki
13RUN make clean && GOARCH=$(cat /goarch) GOARM=$(cat /goarm) make BUILD_IN_CONTAINER=false loki
14
15FROM alpine:3.13
16
17RUN apk add --no-cache ca-certificates
18
19COPY --from=build /src/loki/cmd/loki/loki /usr/bin/loki
20COPY cmd/loki/loki-local-config.yaml /etc/loki/local-config.yaml
21
22RUN addgroup -g 10001 -S loki && \
23    adduser -u 10001 -S loki -G loki
24RUN mkdir -p /loki && \
25    chown -R loki:loki /etc/loki /loki
26
27# See https://github.com/grafana/loki/issues/1928
28RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf
29
30USER loki
31EXPOSE 3100
32ENTRYPOINT [ "/usr/bin/loki" ]
33CMD ["-config.file=/etc/loki/local-config.yaml"]
34