pipecd icon indicating copy to clipboard operation
pipecd copied to clipboard

Generate PIPECD_VERSION before running the service

Open linhdangduy opened this issue 3 months ago β€’ 7 comments

What this PR does:

  • Revert "Revert "Improve make run/pipecd execution 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 by docker/build-push-action github action. Using the same tag value env.PIPECD_VERSION
    • .github/workflows/publish_pipedv1_exp.yaml: add determine version same as publish_image_chart
    • On all Dockerfile / Dockerfile-okd in cmd: receiving BUILD_VERSION and pass to make 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 .dockerignore to exclude unnecessary files from COPY command.
  • When docker image is build, the copied .git within the image will consider that we have removed files so it's git status becomes dirty, that why when git describe --tags --always --dirty... is executed, -dirty suffix 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 -dirty option 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
image

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 build time 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

linhdangduy avatar Sep 17 '25 17:09 linhdangduy

@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 image

linhdangduy avatar Sep 18 '25 00:09 linhdangduy

@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.

khanhtc1202 avatar Sep 18 '25 02:09 khanhtc1202

@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

Warashi avatar Sep 18 '25 21:09 Warashi

@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.

linhdangduy avatar Sep 19 '25 00:09 linhdangduy

@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 πŸ™‡πŸΌ

linhdangduy avatar Sep 28 '25 16:09 linhdangduy

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     
Flag Coverage Ξ”
. ?
.-pkg-app-pipedv1-plugin-analysis ?
.-pkg-app-pipedv1-plugin-kubernetes ?
.-pkg-app-pipedv1-plugin-kubernetes_multicluster 67.63% <ΓΈ> (ΓΈ)
.-pkg-app-pipedv1-plugin-scriptrun ?
.-pkg-app-pipedv1-plugin-terraform ?
.-pkg-app-pipedv1-plugin-wait ?
.-pkg-app-pipedv1-plugin-waitapproval ?
.-pkg-plugin-sdk ?
.-tool-actions-gh-release ?
.-tool-actions-plan-preview ?
.-tool-codegen-protoc-gen-auth ?

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.

codecov[bot] avatar Oct 13 '25 06:10 codecov[bot]

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.

github-actions[bot] avatar Nov 13 '25 00:11 github-actions[bot]

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.

github-actions[bot] avatar Dec 14 '25 00:12 github-actions[bot]