Skip to content

Commit

Permalink
set tag into variable "Version" when docker build (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
elopsod authored May 22, 2024
1 parent cfe6192 commit 9a6ebad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/release-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM golang:alpine AS builder
ARG VERSION

RUN apk update && apk add --no-cache git

Expand All @@ -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
Expand All @@ -19,4 +22,4 @@ FROM scratch
COPY --from=builder /go/bin/medusa /medusa
COPY --from=builder /etc/passwd /etc/passwd
USER scratchuser
ENTRYPOINT ["/medusa"]
ENTRYPOINT ["/medusa"]

0 comments on commit 9a6ebad

Please sign in to comment.