Generate PIPECD_VERSION before running the service
What this PR does:
- Revert "Revert "Improve
make run/pipecdexecution speed (#6184)" (#6235)" - pass BUILD_VERSION to the docker build
Makefile: build/web, run/pipecd.github/workflows/publish_image_chart.yaml: pass by build-args option provided bydocker/build-push-actiongithub action. Using the same tag value env.PIPECD_VERSION.github/workflows/publish_pipedv1_exp.yaml: add determine version same aspublish_image_chart- On all Dockerfile / Dockerfile-okd in
cmd: receiving BUILD_VERSION and pass tomake build/go
- for yarn build / dev script, use the env variable PIPECD_VERSION if exists
Why we need it:
The reason -dirty got attached for the version on #6184 is:
- In Dockerfile, we only COPY what are necessary for the docker build, and there is also
.dockerignoreto exclude unnecessary files from COPY command. - When docker image is build, the copied
.gitwithin the image will consider that we have removed files so it's git status becomesdirty, that why whengit describe --tags --always --dirty...is executed,-dirtysuffix will be attached to the git tag version. https://github.com/pipe-cd/pipecd/pull/6184#issuecomment-3301687814
To resolve above issue:
- ~Just remove the
-dirtyoption from git command~ πΈ - Get the correct BUILD_VERSION first then pass to docker build as argument, then assign it to the web and go build.
- on local: it will get the version from local git
- on github action build: it will get version on committed code.
Evidence:
| action | evidence |
|---|---|
| run the web | dirty has gone |
Which issue(s) this PR fixes:
Fixes https://github.com/pipe-cd/pipecd/pull/6184#issuecomment-3301687814
Does this PR introduce a user-facing change?:
- How are users affected by this change: No
- Is this breaking change: No
- How to migrate (if breaking change):
What I have noticed but not do in this PR:
- probably we can speed up the
docker buildtime of other Dockerfile (launcher / pipectl / piped...) by copy only what necessary. But I decided to keep this PR as a fix of #6184, and make sure if we can go with this change and confirm it is worked
@Warashi Can you try execute make stop/pipecd once before make run/pipecd, and see the result?
As evidence share in the PR's description, I see that the version is available at the top header, and also in the menu tab
@linhdangduy Thanks for the patch π
I also found another place that we needed to check, which is make build/go MOD=piped. This is the bug I found with v0.54.0 (the always -dirty version)
β― docker run --rm -it --entrypoint /bin/sh ghcr.io/pipe-cd/piped:v0.54.0
/ $ piped version
Version: v0.54.0-dirty, GitCommit: 025ac2ec2d7b7edcc774a3cc548819e9c9fc9c6d, BuildDate: 20250916-063057
I think it's caused by the Dockerignore, which makes Docker ignore files that are watched by git.
@linhdangduy
I retried and got the same result.
As far as I know, the docker build doesn't carry environment variables to container image. So it's not the correct way that we pass the PIPECD_VERSION as the environment variable when running the docker build.
Alternatively, we can use ARG in the Dockerfile and pass argument with --build-arg option.
ref; https://docs.docker.com/reference/dockerfile/#arg
@khanhtc1202 @Warashi Thank you for the suggestion! ππΌ
Understood the root cause that piped (and builds that are not pipecd) build also produce -dirty tag is we have .dockerignore exclude the files watch by git. The viable option is just have .dockerignore content same with .gitignore, so there should be no -dirty
And for pipecd build, both .dockerignore and selective copy (only copy some of the local content to docker image) cause the issue.
Let's me check how can the issue be resolved.
@Warashi @khanhtc1202 @ffjlabo Sorry for the trouble on the previous #6184 PR. I have pushed the fix of the root cause of the error. The solution is getting BUILD_VERSION first, then passing it to the docker build. The reason I still would like to this is we will have fast build time for pipecd, accelerate the local dev experience for dev.
Please also refer to the PR's description and review when you have time ππΌ
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 67.63%. Comparing base (738066c) to head (0bf18ef).
:warning: Report is 48 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #6239 +/- ##
===========================================
+ Coverage 28.83% 67.63% +38.79%
===========================================
Files 560 25 -535
Lines 59899 2283 -57616
===========================================
- Hits 17273 1544 -15729
+ Misses 41304 651 -40653
+ Partials 1322 88 -1234
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.