From 7226277e841f26afda41deabe005d4ff7b3f3c91 Mon Sep 17 00:00:00 2001 From: JustSong Date: Sat, 10 Dec 2022 15:06:30 +0800 Subject: [PATCH] fix: set version info for Docker image --- .github/workflows/docker-image.yml | 4 ++++ Dockerfile | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index e28ab3e..b4e891b 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -20,6 +20,10 @@ jobs: - name: Check out the repo uses: actions/checkout@v3 + - name: Save version info + run: | + git describe --tags > VERSION + - name: Log in to Docker Hub uses: docker/login-action@v2 with: diff --git a/Dockerfile b/Dockerfile index 2daae2c..b7a4075 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,9 @@ FROM node:16 as builder WORKDIR /build COPY ./web . +COPY ./VERSION . RUN npm install -RUN npm run build +RUN REACT_APP_VERSION=$(cat VERSION) npm run build FROM golang AS builder2 @@ -15,7 +16,7 @@ WORKDIR /build COPY . . COPY --from=builder /build/build ./web/build RUN go mod download -RUN go build -ldflags "-s -w -extldflags '-static'" -o gin-template +RUN go build -ldflags "-s -w -X 'gin-template/common.Version=$(cat VERSION)' -extldflags '-static'" -o gin-template FROM alpine