Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 16, 2025

The version number displayed in the footer was hardcoded from package.json. Release builds need to inject the git tag (e.g., v6.10.7) and commit SHA into the Docker image using build arguments.

Changes

Build arguments approach

  • Dockerfile accepts VERSION and COMMIT_SHA as build arguments (defaults: 0.0.0 and unknown)
  • Vite's define feature injects these values as build-time constants (__APP_VERSION__, __APP_COMMIT_SHA__)
  • Values are statically bundled into the client JavaScript

Docker configuration

  • Dockerfile: Accepts VERSION and COMMIT_SHA build args, creates VERSION and COMMIT_SHA files, passes values to Vite as environment variables
  • Dockerfile.dev: Echoes "dev" to both VERSION and COMMIT_SHA files for development

Frontend

  • Updated useAppStore.ts to use build-time constants instead of package.json
  • Footer displays: v{version} ({first 6 chars of commit SHA})
  • Commit SHA hidden if value is "unknown"
  • Created vite-env.d.ts for TypeScript declarations

GitHub workflow

  • Updated .github/workflows/push-image.yml to extract version from git tag (strips "v" prefix)
  • Extracts first 6 characters of commit SHA
  • Passes both as build arguments to docker build

Git ignore

  • Added VERSION to .gitignore

Usage

For production releases:

docker build -t dc-lineage-builder:6.10.7 . \
  --build-arg VERSION=6.10.7 \
  --build-arg COMMIT_SHA=$(git rev-parse --short HEAD)

The GitHub workflow automatically extracts and passes these values during release builds. Version and commit SHA are statically bundled into the client JavaScript during the build process.

Original prompt

This section details on the original issue you should resolve

<issue_title>Version number</issue_title>
<issue_description>When publishing a new release (for example, v6.10.7):

  • The tag, as 6.10.7, should be baked into the docker image, as the file VERSION.

The VERSION file should be ignored by git.

When building the Dockerfile for production or dev, if no VERSION file is present, a dummy of 0.0.0 should be created to avoid non-existant file problems.

The client bundle currently displays the version number extracted from package.json in the footer. This needs to be changed to reference the newly generated file and be bundled statically in the client bundle.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits November 16, 2025 15:42
- Add VERSION to .gitignore
- Update Dockerfiles to create default VERSION file (0.0.0)
- Create generate-version.js script to read VERSION and generate version.ts
- Update package.json to run version generation before builds
- Update useAppStore.ts to import version from generated file instead of package.json
- Add version.ts to .gitignore as it's auto-generated

Co-authored-by: edenchazard <[email protected]>
- Update README.md with instructions on building with version number
- Add explanatory comments to Dockerfile about VERSION file behavior

Co-authored-by: edenchazard <[email protected]>
- Improve error handling in generate-version.js with specific messages
- Fix Dockerfile race condition by creating VERSION after COPY
- Update Dockerfile.dev with clearer comment about VERSION handling
- Test fallback behavior when VERSION file is missing

Co-authored-by: edenchazard <[email protected]>
Copilot AI changed the title [WIP] Add version number to Docker image and client bundle Implement VERSION file for Docker image versioning Nov 16, 2025
Copilot AI requested a review from edenchazard November 16, 2025 15:50
Copilot finished work on behalf of edenchazard November 16, 2025 15:50
Copy link
Owner

@edenchazard edenchazard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You misunderstood me. When the push image workflow is in process, and we are building the image, we should pass the version as the build arg to docker build. This workflow can be found at https://github.com/edenchazard/dc-lineage-builder/blob/main/.github/workflows/push-image.yml

Additionally, as a second requirement: also pass the commit reference as a build arg, and include the 6 digit commit reference in the footer, alongside where the version number is.

package.json Outdated
Comment on lines 9 to 11
"vue:start": "node generate-version.js && vite --host",
"vue:preview": "vite preview",
"vue:build": "vite build",
"vue:build": "node generate-version.js && vite build",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't bother with the generate.js script and invoking it in these scripts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed generate-version.js and its script invocations. Now using Vite's define feature with build args instead. Changes in commit 04ed0bb.

Dockerfile.dev Outdated
WORKDIR /app
COPY package*.json ./
RUN npm ci
# Note: VERSION file should be bind-mounted or created in docker-compose for dev
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Just echo a dev to the VERSION file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated Dockerfile.dev to echo "dev" to VERSION file (and COMMIT_SHA as well). Changes in commit 04ed0bb.

- Remove generate-version.js script and its invocations from package.json
- Use Vite's define feature to inject VERSION and COMMIT_SHA at build time
- Update Dockerfile to accept VERSION and COMMIT_SHA as build arguments
- Update Dockerfile.dev to echo "dev" for both VERSION and COMMIT_SHA
- Update GitHub workflow to pass version and commit SHA as build args
- Add commit SHA display in footer (first 6 characters)
- Create vite-env.d.ts for TypeScript declarations
- Update README with new build argument approach
- Remove version.ts from .gitignore

Co-authored-by: edenchazard <[email protected]>
Copy link
Contributor Author

Copilot AI commented Dec 1, 2025

You misunderstood me. When the push image workflow is in process, and we are building the image, we should pass the version as the build arg to docker build. This workflow can be found at https://...

Updated to pass VERSION and COMMIT_SHA as build args in the GitHub workflow. The footer now displays both the version and the first 6 characters of the commit SHA. Changes in commit 04ed0bb.

- Add comment explaining ARG variables are available throughout the build stage
- Add comment to Dockerfile.dev explaining why files are used instead of ARGs

Co-authored-by: edenchazard <[email protected]>
Copilot AI changed the title Implement VERSION file for Docker image versioning Implement VERSION and COMMIT_SHA using Docker build arguments Dec 1, 2025
Copilot AI requested a review from edenchazard December 1, 2025 17:45
Copilot finished work on behalf of edenchazard December 1, 2025 17:45
@edenchazard edenchazard marked this pull request as ready for review December 1, 2025 18:35
@edenchazard
Copy link
Owner

Honestly, robot, you were shit at this. I've had to do it myself.

@edenchazard edenchazard merged commit fb1e0c3 into main Dec 1, 2025
1 check passed
@edenchazard edenchazard deleted the copilot/add-version-number-to-docker-image branch December 1, 2025 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Version number

2 participants