Skip to content

Commit

Permalink
chore: add version to binary in containers
Browse files Browse the repository at this point in the history
  • Loading branch information
ChibangLW committed Jun 18, 2022
1 parent 3ae3405 commit d4a550b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Expand Up @@ -89,6 +89,8 @@ jobs:
platforms: linux/amd64,linux/arm64
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
build-args: |
VERSION=${{ github.ref_name }}
- name: Prepare cache for next build
run: |
rm -rf /tmp/.buildx-cache
Expand Down Expand Up @@ -153,6 +155,8 @@ jobs:
platforms: linux/amd64,linux/arm64
cache-from: type=local,src=/tmp/.buildx-cache-debug
cache-to: type=local,dest=/tmp/.buildx-cache-debug-new
build-args: |
VERSION=${{ github.ref_name }}
- name: Prepare cache for next build
run: |
rm -rf /tmp/.buildx-cache-debug
Expand Down Expand Up @@ -217,6 +221,8 @@ jobs:
platforms: linux/amd64,linux/arm64
cache-from: type=local,src=/tmp/.buildx-cache-alpine
cache-to: type=local,dest=/tmp/.buildx-cache-alpine-new
build-args: |
VERSION=${{ github.ref_name }}
- name: Prepare cache for next build
run: |
rm -rf /tmp/.buildx-cache-alpine
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
@@ -1,5 +1,6 @@
# Builder image
FROM docker.io/golang:1.18.0-bullseye AS build
ARG VERSION=dev
ENV GOPATH /go
WORKDIR /go/src/headscale

Expand All @@ -8,7 +9,7 @@ RUN go mod download

COPY . .

RUN CGO_ENABLED=0 GOOS=linux go install -a ./cmd/headscale
RUN CGO_ENABLED=0 GOOS=linux go install -ldflags="-s -w -X github.com/juanfont/headscale/cmd/headscale/cli.Version=$VERSION" -a ./cmd/headscale
RUN strip /go/bin/headscale
RUN test -e /go/bin/headscale

Expand Down
3 changes: 2 additions & 1 deletion Dockerfile.alpine
@@ -1,5 +1,6 @@
# Builder image
FROM docker.io/golang:1.18.0-alpine AS build
ARG VERSION=dev
ENV GOPATH /go
WORKDIR /go/src/headscale

Expand All @@ -9,7 +10,7 @@ RUN go mod download

COPY . .

RUN CGO_ENABLED=0 GOOS=linux go install -a ./cmd/headscale
RUN CGO_ENABLED=0 GOOS=linux go install -ldflags="-s -w -X github.com/juanfont/headscale/cmd/headscale/cli.Version=$VERSION" -a ./cmd/headscale
RUN strip /go/bin/headscale
RUN test -e /go/bin/headscale

Expand Down
3 changes: 2 additions & 1 deletion Dockerfile.debug
@@ -1,5 +1,6 @@
# Builder image
FROM docker.io/golang:1.18.0-bullseye AS build
ARG VERSION=dev
ENV GOPATH /go
WORKDIR /go/src/headscale

Expand All @@ -8,7 +9,7 @@ RUN go mod download

COPY . .

RUN CGO_ENABLED=0 GOOS=linux go install -a ./cmd/headscale
RUN CGO_ENABLED=0 GOOS=linux go install -ldflags="-s -w -X github.com/juanfont/headscale/cmd/headscale/cli.Version=$VERSION" -a ./cmd/headscale
RUN test -e /go/bin/headscale

# Debug image
Expand Down

0 comments on commit d4a550b

Please sign in to comment.