-
Notifications
You must be signed in to change notification settings - Fork 14
/
Dockerfile
36 lines (24 loc) · 1020 Bytes
/
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
FROM golang:1.23.3-alpine as base_builder
RUN apk --no-cache add ca-certificates git
WORKDIR /go/src/github.com/Templum/rabbitmq-connector/
ENV GO111MODULE=on
COPY go.mod go.sum ./
RUN go mod download
FROM base_builder as builder
COPY . .
RUN VERSION=$(git describe --all --exact-match $(git rev-parse HEAD) | grep tags | sed 's/tags\///') && \
GIT_COMMIT=$(git describe --always) && \
echo "Git TAG: $VERSION GIT Commit: $GIT_COMMIT" && \
CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w \
-X github.com/Templum/rabbitmq-connector/pkg/version.Version=${VERSION} \
-X github.com/Templum/rabbitmq-connector/pkg/version.GitCommit=${GIT_COMMIT}" \
-a -installsuffix cgo -o rmq-connector .
FROM alpine:3.20.3
RUN addgroup -S app \
&& adduser -S -g app app \
&& apk --no-cache add ca-certificates
WORKDIR /home/app
COPY --from=builder /go/src/github.com/Templum/rabbitmq-connector/rmq-connector .
RUN chown -R app:app ./
USER app
ENTRYPOINT ["./rmq-connector"]