forked from grafana/alloy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
65 lines (51 loc) · 2 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# syntax=docker/dockerfile:1.4
# NOTE: This Dockerfile can only be built using BuildKit. BuildKit is used by
# default when running `docker buildx build` or when DOCKER_BUILDKIT=1 is set
# in environment variables.
FROM --platform=$BUILDPLATFORM grafana/alloy-build-image:v0.1.1 as build
ARG BUILDPLATFORM
ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
ARG RELEASE_BUILD=1
ARG VERSION
ARG GOEXPERIMENT
COPY . /src/alloy
WORKDIR /src/alloy
# Build the UI before building Alloy, which will then bake the final UI into
# the binary.
RUN --mount=type=cache,target=/src/alloy/web/ui/node_modules,sharing=locked \
make generate-ui
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
GOOS=$TARGETOS GOARCH=$TARGETARCH GOARM=${TARGETVARIANT#v} \
RELEASE_BUILD=${RELEASE_BUILD} VERSION=${VERSION} \
GO_TAGS="netgo builtinassets promtail_journal_enabled" \
GOEXPERIMENT=${GOEXPERIMENT} \
make alloy
FROM public.ecr.aws/ubuntu/ubuntu:mantic
# Username and uid for alloy user
ARG UID=473
ARG USERNAME="alloy"
LABEL org.opencontainers.image.source="https://github.com/grafana/alloy"
# Install dependencies needed at runtime.
RUN apt-get update \
&& apt-get install -qy libsystemd-dev tzdata ca-certificates \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY --from=build /src/alloy/build/alloy /bin/alloy
COPY example-config.alloy /etc/alloy/config.alloy
# Create alloy user in container, but do not set it as default
#
# NOTE(rfratto): non-root support in Docker containers is an experimental,
# undocumented feature; use at your own risk.
RUN groupadd --gid $UID $USERNAME
RUN useradd -m -u $UID -g $UID $USERNAME
RUN chown -R $USERNAME:$USERNAME /etc/alloy
RUN chown -R $USERNAME:$USERNAME /bin/alloy
RUN mkdir -p /var/lib/alloy/data
RUN chown -R $USERNAME:$USERNAME /var/lib/alloy
RUN chmod -R 770 /var/lib/alloy
ENTRYPOINT ["/bin/alloy"]
ENV ALLOY_DEPLOY_MODE=docker
CMD ["run", "/etc/alloy/config.alloy", "--storage.path=/var/lib/alloy/data"]