-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathContainerfile
64 lines (51 loc) · 1.82 KB
/
Containerfile
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
# Base image for build
ARG base_image_version=1.22
# We are doing cross compilation, this speeds things up
# https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/
FROM --platform=$BUILDPLATFORM golang:${base_image_version} as builder
# Switch workdir
WORKDIR /opt/apm-perf
# Use dedicated layer for Go dependency, cached until they changes
COPY go.mod go.sum ./
RUN go mod download
# Copy files
COPY . .
# Build
ARG TARGETOS TARGETARCH
ENV GOOS=$TARGETOS
ENV GOARCH=$TARGETARCH
ENV CGO_ENABLED=0
# Leverage mounts to cache relevant Go paths
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
make build
# Base image for final image
FROM cgr.dev/chainguard/static
# Arguments
ARG commit_sha
ARG current_time
ARG image_id
ARG project_url
# Labels
LABEL \
org.opencontainers.image.created="${current_time}" \
org.opencontainers.image.authors="amannocci <[email protected]>" \
org.opencontainers.image.url="${project_url}" \
org.opencontainers.image.documentation="${project_url}" \
org.opencontainers.image.source="${project_url}" \
org.opencontainers.image.version="${image_id}" \
org.opencontainers.image.revision="${commit_sha}" \
org.opencontainers.image.vendor="Elastic" \
org.opencontainers.image.licenses="Elastic License 2.0"
# Switch workdir
WORKDIR /opt/apm-perf
# Copy files for apmsoak
COPY --from=builder /opt/apm-perf/dist/apmsoak /usr/bin/apmsoak
COPY ./internal/loadgen/events ./events
COPY ./cmd/apmsoak/scenarios.yml /opt/apm-perf/scenarios.yml
# Copy files for apmbench
COPY --from=builder /opt/apm-perf/dist/apmbench /usr/bin/apmbench
# Copy files for apmtelemetrygen
COPY --from=builder /opt/apm-perf/dist/apmtelemetrygen /usr/bin/apmtelemetrygen
# Default to apmsoak, override to use apmbench
CMD [ "/usr/bin/apmsoak" ]