Open srikanthccv opened 1 year ago
In the same area: For better local reproducibility of the builds it would be nice to have a multi stage docker build instead of a build partly done in the actions through the makefile and partly done as docker image. I am thinking of something like this:
# syntax=docker/dockerfile:1
# Build the application from source
FROM golang:1.21.0-alpine3.17 AS build-stage
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
RUN apk add build-base
COPY ./ ./
RUN CGO_ENABLED=1 go build -tags timetzdata -o .build/linux-amd64/signoz-collector -ldflags "-linkmode external -extldflags '-static' -s -w" ./cmd/signozcollector
# use a minimal alpine image
FROM alpine:3.17
# add ca-certificates in case you need them
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
# define arguments and default values
ARG USER_UID=10001
# create a non-root user for running the collector
USER ${USER_UID}
# copy the binaries from the multi-stage build
COPY --from=build-stage /app/.build/linux-amd64/signoz-collector /signoz-collector
# copy the config and migration files
COPY config/default-config.yaml /etc/otel/config.yaml
COPY exporter/clickhousetracesexporter/migrations /migrations
COPY exporter/clickhouselogsexporter/migrations /logsmigrations
ENV LOG_MIGRATIONS_FOLDER="/logsmigrations"
# expose OTLP ports for the collector
EXPOSE 4317 4318
# run the binary as the entrypoint and pass the default config file as a flag
ENTRYPOINT [ "/signoz-collector" ]
CMD ["--config", "/etc/otel/config.yaml"]
Find a unified and consistent way to manager binary and docker builds across the environments (which is not the case today)