Repository navigation
Add live version to web interface from git tags via Makefile - #61
Conversation
- Create Makefile that reads git tag version via `git describe` - Pass APP_VERSION as Docker build arg through docker-compose.yml - Update all Dockerfiles to accept APP_VERSION build arg and set as env var - Read APP_VERSION env var in web service instead of hard-coded config value - Log app version at web service boot - Fall back to config.json version if env var not set Agent-Logs-Url: https://github.com/maxi07/ScanSync/sessions/1ae7444f-19ab-4386-b174-a6292ff5885d Co-authored-by: maxi07 <7480270+maxi07@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR replaces the web UI’s hard-coded version with a dynamic version derived from git describe, propagated through Docker build args into container environment variables, and surfaced via the Flask template context.
Changes:
- Add a repository
Makefileintended to compute/exportAPP_VERSIONfromgit describeand provide commondocker composetargets. - Pass
APP_VERSIONas a Docker build arg indocker-compose.yml/docker-compose.test.ymland set it as an image env var viaARG/ENVin multiple service Dockerfiles. - Update the web service to log and inject
APP_VERSION(with a config fallback) into templates.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| web_service/src/main.py | Logs and injects APP_VERSION into the Flask template context for display in the UI. |
| web_service/Dockerfile | Accepts APP_VERSION as a build arg and sets it as an image env var. |
| upload_service/Dockerfile | Accepts APP_VERSION as a build arg and sets it as an image env var. |
| ocr_service/Dockerfile | Accepts APP_VERSION as a build arg and sets it as an image env var. |
| metadata_service/Dockerfile | Accepts APP_VERSION as a build arg and sets it as an image env var. |
| file_naming_service/Dockerfile | Accepts APP_VERSION as a build arg and sets it as an image env var. |
| detection_service/Dockerfile | Accepts APP_VERSION as a build arg and sets it as an image env var. |
| docker-compose.yml | Wires APP_VERSION through build args for most built services. |
| docker-compose.test.yml | Wires APP_VERSION through build args for the web-service test build. |
| Makefile | Adds git describe-based version resolution and common lifecycle/test targets. |
| start: | ||
| @echo "Starting ScanSync (Version: $(GIT_VERSION))..." | ||
| APP_VERSION=$(GIT_VERSION) $(DOCKER_COMPOSE) up --build -d | ||
|
|
There was a problem hiding this comment.
Fixed. Removed the inline APP_VERSION=$(GIT_VERSION) override from the start recipe — the exported $(APP_VERSION) variable is now passed implicitly.
| .PHONY: build | ||
| build: | ||
| @echo "Building ScanSync (Version: $(GIT_VERSION))..." | ||
| APP_VERSION=$(GIT_VERSION) $(DOCKER_COMPOSE) build | ||
|
|
There was a problem hiding this comment.
Fixed. Same as start — removed the inline APP_VERSION=$(GIT_VERSION) from the build recipe so the exported variable is used consistently.
| return dict( | ||
| failed_document_count=failed_document_count, | ||
| version=config.get("version", "Unknown"), | ||
| version=os.environ.get("APP_VERSION", config.get("version", "Unknown")), | ||
| onedrive_token_error=is_token_expired(), |
There was a problem hiding this comment.
Fixed. Changed to os.environ.get("APP_VERSION") or config.get("version", "Unknown") so an empty-string APP_VERSION correctly falls back to the config value.
| context: . | ||
| dockerfile: ocr_service/Dockerfile | ||
| args: | ||
| - APP_VERSION=${APP_VERSION:-dev} | ||
| restart: unless-stopped |
There was a problem hiding this comment.
Fixed. Converted smb_service to the long build syntax with APP_VERSION=${APP_VERSION:-dev} build arg, and added ARG APP_VERSION=dev / ENV APP_VERSION=${APP_VERSION} to its Dockerfile.
| build: | ||
| context: . | ||
| dockerfile: web_service/Dockerfile | ||
| args: | ||
| - APP_VERSION=${APP_VERSION:-dev} |
There was a problem hiding this comment.
Fixed. Added APP_VERSION=${APP_VERSION:-dev} build arg to test_service in docker-compose.test.yml and the corresponding ARG/ENV instructions to test_service/Dockerfile.
…ervice build args
* Initial plan * Add dynamic version from git tags via Makefile and Docker build args - Create Makefile that reads git tag version via `git describe` - Pass APP_VERSION as Docker build arg through docker-compose.yml - Update all Dockerfiles to accept APP_VERSION build arg and set as env var - Read APP_VERSION env var in web service instead of hard-coded config value - Log app version at web service boot - Fall back to config.json version if env var not set Agent-Logs-Url: https://github.com/maxi07/ScanSync/sessions/1ae7444f-19ab-4386-b174-a6292ff5885d * Fix review comments: APP_VERSION override, fallback logic, smb/test service build args --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: maxi07 <7480270+maxi07@users.noreply.github.com>
Replace hard-coded version string with dynamic version derived from
git describe --tags --always --dirty, passed through the Docker build pipeline as an environment variable.Makefile
Makefilewithstart,stop,build,restart,clean,testtargetsgit describeand exports asAPP_VERSIONDocker build pipeline
docker-compose.yml/docker-compose.test.yml: passAPP_VERSIONas build arg to all services (default:dev)ARG APP_VERSION=dev, setENV APP_VERSIONWeb service
inject_config()readsos.environ.get("APP_VERSION")with fallback toconfig.jsonUsage: