From bb66a8b791bc486c109cb2dd4392fd429a30c435 Mon Sep 17 00:00:00 2001 From: Googol Lee Date: Tue, 27 Aug 2024 21:46:29 +0200 Subject: [PATCH] Fix release version and date in UI. (#1025) --- .github/workflows/build.yml | 3 +++ Dockerfile | 6 +++++- README.md | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3b754afa..448fa89b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -70,3 +70,6 @@ jobs: push: ${{ github.event_name != 'pull_request' && github.repository == 'photoview/photoview' }} tags: ${{ steps.docker_meta.outputs.tags }} labels: ${{ steps.docker_meta.outputs.labels }} + build-args: | + VERSION=${{ github.ref_name }} + COMMIT_SHA=${{ github.sha }} diff --git a/Dockerfile b/Dockerfile index f1046083..25d90934 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,11 @@ COPY ui/package.json ui/package-lock.json /app/ui RUN npm ci COPY ui/ /app/ui -RUN npm run build -- --base=$UI_PUBLIC_URL +RUN if [ "$BUILD_DATE" = "" ]; then \ + export BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ'); \ + export REACT_APP_BUILD_DATE=${BUILD_DATE}; \ + fi; \ + npm run build -- --base=$UI_PUBLIC_URL ### Build API ### FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.22-bookworm AS api diff --git a/README.md b/README.md index 67852323..7f7f9d3c 100644 --- a/README.md +++ b/README.md @@ -220,6 +220,8 @@ It may take a long time to build dependencies when launching servers first time. ```sh $ docker build --target ui -t photoview/ui . # Build image for development +$ docker run --rm -it -v `pwd`:/app --network host --env-file ui/example.env photoview/ui \ + npm install # Install dependencies $ docker run --rm -it -v `pwd`:/app --network host --env-file ui/example.env photoview/ui \ npm run mon # Monitor source code and (re)launch UI server ```