embedd version info into docker image binary

This commit is contained in:
Matthew R. Kasun 2022-02-12 11:55:54 -05:00
parent 4e8bf0c763
commit 6cd0858556
2 changed files with 5 additions and 3 deletions

View file

@ -47,6 +47,7 @@ jobs:
load: true
platforms: linux/amd64
tags: ${{ env.TAG }}
build-args: version=${{ env.TAG }}
-
name: Test x86
run: |
@ -61,6 +62,7 @@ jobs:
load: true
platforms: linux/arm64
tags: ${{ env.TAG }}
build-args: version=${{ env.TAG }}
-
name: Test arm
run: |
@ -75,3 +77,4 @@ jobs:
platforms: linux/amd64, linux/arm64
push: true
tags: ${{ github.repository }}:${{ env.TAG }}
build-args: version=${{ env.TAG }}

View file

@ -1,13 +1,12 @@
#first stage - builder
FROM golang:1.17-alpine as builder
ARG version
ARG VERSION
RUN apk add build-base
WORKDIR /app
COPY . .
ENV GO111MODULE=auto
# RUN GOOS=linux CGO_ENABLED=1 go build -tags debug -ldflags="-s -X 'main.version=$version'" -o netmaker main.go
RUN GOOS=linux CGO_ENABLED=1 go build -ldflags="-s -X 'main.version=$VERSION'" -o netmaker main.go
RUN GOOS=linux CGO_ENABLED=1 go build -ldflags="-s -X 'main.version=${VERSION}'" -o netmaker main.go
FROM alpine:3.14.3
# add a c lib