Skip to content

Commit 1fb8206

Browse files
Rakshitha-KamathRakshitha-Kamath
authored andcommitted
Add the Dockerfile for RH Builds
1 parent cc0c8e0 commit 1fb8206

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

Dockerfile

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# syntax=docker/dockerfile:1.4
2+
3+
# NOTE: This Dockerfile can only be built using BuildKit. BuildKit is used by
4+
# default when running `docker buildx build` or when DOCKER_BUILDKIT=1 is set
5+
# in environment variables.
6+
7+
FROM --platform=$BUILDPLATFORM grafana/alloy-build-image:v0.1.20 AS ui-build
8+
ARG BUILDPLATFORM
9+
COPY ./internal/web/ui /ui
10+
WORKDIR /ui
11+
RUN --mount=type=cache,target=/ui/node_modules,sharing=locked \
12+
yarn --network-timeout=1200000 \
13+
&& yarn run build
14+
15+
FROM --platform=$BUILDPLATFORM grafana/alloy-build-image:v0.1.20 AS build
16+
17+
ARG BUILDPLATFORM
18+
ARG TARGETPLATFORM
19+
ARG TARGETOS
20+
ARG TARGETARCH
21+
ARG TARGETVARIANT
22+
ARG RELEASE_BUILD=1
23+
ARG VERSION
24+
ARG GOEXPERIMENT
25+
26+
COPY . /src/alloy
27+
WORKDIR /src/alloy
28+
29+
COPY --from=ui-build /ui/build /src/alloy/internal/web/ui/build
30+
31+
RUN --mount=type=cache,target=/root/.cache/go-build \
32+
--mount=type=cache,target=/go/pkg/mod \
33+
GOOS="$TARGETOS" GOARCH="$TARGETARCH" GOARM=${TARGETVARIANT#v} \
34+
RELEASE_BUILD=${RELEASE_BUILD} VERSION=${VERSION} \
35+
GO_TAGS="netgo builtinassets promtail_journal_enabled pyroscope_ebpf" \
36+
GOEXPERIMENT=${GOEXPERIMENT} \
37+
make alloy
38+
39+
###
40+
41+
FROM public.ecr.aws/ubuntu/ubuntu:noble
42+
43+
# Username and uid for alloy user
44+
ARG UID="473"
45+
ARG USERNAME="alloy"
46+
# Force non-interactive mode for tzdata package install
47+
ARG DEBIAN_FRONTEND="noninteractive"
48+
49+
LABEL org.opencontainers.image.source="https://github.com/grafana/alloy"
50+
51+
RUN apt-get update \
52+
&& apt-get upgrade -y \
53+
&& apt-get install -qy --no-install-recommends \
54+
ca-certificates \
55+
libsystemd0 \
56+
tzdata \
57+
&& apt-get clean \
58+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
59+
60+
61+
COPY --from=build --chown=${UID}:${UID} /src/alloy/build/alloy /bin/alloy
62+
COPY --chown=${UID}:${UID} example-config.alloy /etc/alloy/config.alloy
63+
64+
# Create alloy user in container, but do not set it as default
65+
#
66+
# NOTE: non-root support in Docker containers is an experimental,
67+
# undocumented feature; use at your own risk.
68+
RUN groupadd --gid $UID $USERNAME \
69+
&& useradd -m -u $UID -g $UID $USERNAME \
70+
&& mkdir -p /var/lib/alloy/data \
71+
&& chown -R $USERNAME:$USERNAME /var/lib/alloy \
72+
&& chmod -R 770 /var/lib/alloy
73+
74+
ENTRYPOINT ["/bin/alloy"]
75+
ENV ALLOY_DEPLOY_MODE=docker
76+
CMD ["run", "/etc/alloy/config.alloy", "--storage.path=/var/lib/alloy/data"]

0 commit comments

Comments
 (0)