mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-06-21 02:23:12 +08:00

* refactor(query-service): ♻️ Update ldflags and Makefile for dynamic versioning Signed-off-by: Prashant Shahi <prashant@signoz.io> * chore: 🎨 Use blacnk spaces indentation in build details * chore(query-service): 🎨 small build details format changes * refactor(query-service): ♻️ refactor ldflags for go build
51 lines
1.2 KiB
Docker
51 lines
1.2 KiB
Docker
FROM golang:1.14-buster AS builder
|
|
|
|
# LD_FLAGS is passed as argument from Makefile. It will be empty, if no argument passed
|
|
ARG LD_FLAGS
|
|
ARG TARGETPLATFORM
|
|
|
|
ENV CGO_ENABLED=1
|
|
ENV GOPATH=/go
|
|
|
|
RUN export GOOS=$(echo ${TARGETPLATFORM} | cut -d / -f1) && \
|
|
export GOARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2)
|
|
|
|
# Prepare and enter src directory
|
|
WORKDIR /go/src/github.com/signoz/signoz/pkg/query-service
|
|
|
|
# Cache dependencies
|
|
ADD go.mod .
|
|
ADD go.sum .
|
|
RUN go mod download -x
|
|
|
|
# Add the sources and proceed with build
|
|
ADD . .
|
|
RUN go build -a -ldflags "-linkmode external -extldflags '-static' -s -w $LD_FLAGS" -o ./bin/query-service ./main.go
|
|
RUN chmod +x ./bin/query-service
|
|
|
|
|
|
# use a minimal alpine image
|
|
FROM alpine:3.7
|
|
|
|
# Add Maintainer Info
|
|
LABEL maintainer="signoz"
|
|
|
|
# add ca-certificates in case you need them
|
|
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
|
|
|
|
# set working directory
|
|
WORKDIR /root
|
|
|
|
# copy the binary from builder
|
|
COPY --from=builder /go/src/github.com/signoz/signoz/pkg/query-service/bin/query-service .
|
|
|
|
COPY config/prometheus.yml /root/config/prometheus.yml
|
|
|
|
# run the binary
|
|
ENTRYPOINT ["./query-service"]
|
|
|
|
CMD ["-config", "/root/config/prometheus.yml"]
|
|
# CMD ["./query-service -config /root/config/prometheus.yml"]
|
|
|
|
EXPOSE 8080
|