diff --git a/.github/workflows/release-docker.yml b/.github/workflows/release-docker.yml index 81caa50..39aefa6 100644 --- a/.github/workflows/release-docker.yml +++ b/.github/workflows/release-docker.yml @@ -33,6 +33,8 @@ jobs: with: context: . push: true + build-args: | + VERSION=${{ env.TAG }} tags: | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }} \ No newline at end of file + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }} diff --git a/Dockerfile b/Dockerfile index 19f63cf..37d0bf2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM golang:alpine AS builder +ARG VERSION RUN apk update && apk add --no-cache git @@ -10,7 +11,9 @@ ADD . . RUN go mod download RUN go get -d -v -RUN CGO_ENABLED=0 GOOS=linux go build -o /go/bin/medusa +RUN CGO_ENABLED=0 GOOS=linux go build \ + -ldflags="-X 'github.com/jonasvinther/medusa/cmd.Version=${VERSION}'" \ + -o /go/bin/medusa RUN adduser -S scratchuser RUN chown scratchuser /go/bin/medusa @@ -19,4 +22,4 @@ FROM scratch COPY --from=builder /go/bin/medusa /medusa COPY --from=builder /etc/passwd /etc/passwd USER scratchuser -ENTRYPOINT ["/medusa"] \ No newline at end of file +ENTRYPOINT ["/medusa"]