Skip to content

Conversation

@linhdangduy
Copy link
Contributor

@linhdangduy linhdangduy commented Sep 17, 2025

What this PR does:

  • Revert "Revert "Improve make run/pipecd execution speed (Improve make run/pipecd execution speed #6184)" (Revert "Improve make run/pipecd execution speed" #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. Improve make run/pipecd execution speed #6184 (comment)

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 #6184 (comment)

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 Improve make run/pipecd execution speed #6184, and make sure if we can go with this change and confirm it is worked

@linhdangduy linhdangduy force-pushed the web-generate-pipecd-version-based-only-on-web-folder branch from 287fe2d to d6f5c81 Compare September 17, 2025 17:12
@linhdangduy linhdangduy changed the title web generate pipecd version based only on web folder Generate PIPECD_VERSION before running the service Sep 17, 2025
@linhdangduy linhdangduy marked this pull request as ready for review September 17, 2025 17:49
@linhdangduy linhdangduy requested review from a team as code owners September 17, 2025 17:49
@linhdangduy linhdangduy force-pushed the web-generate-pipecd-version-based-only-on-web-folder branch from d6f5c81 to 46629ac Compare September 17, 2025 17:58
Copy link
Member

@Warashi Warashi left a comment

Choose a reason for hiding this comment

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

I checked on my local machine and got unexpected behavior.
We expect to see control plane version at the last of the menu, but it's lacking.

  • screenshot with demo.pipecd.dev
    Image

  • screenshot with this PR on my local
    Image

@linhdangduy
Copy link
Contributor Author

@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

@khanhtc1202
Copy link
Member

khanhtc1202 commented Sep 18, 2025

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

@Warashi
Copy link
Member

Warashi commented Sep 18, 2025

@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

@linhdangduy
Copy link
Contributor Author

@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 linhdangduy force-pushed the web-generate-pipecd-version-based-only-on-web-folder branch 3 times, most recently from 12edfa9 to f726c0c Compare September 28, 2025 15:25
@linhdangduy linhdangduy force-pushed the web-generate-pipecd-version-based-only-on-web-folder branch from 81e889b to 989b9c7 Compare September 28, 2025 15:49
web/package.json Outdated
Comment on lines 8 to 9
"build": "PIPECD_VERSION=${PIPECD_VERSION:-`git describe --tags --always --dirty --abbrev=7 --match 'v[0-9]*.*'`} webpack build --mode production --env htmlTemplate=./base.html --config ./webpack.config.js",
"dev": "PIPECD_VERSION=${PIPECD_VERSION:-`git describe --tags --always --dirty --abbrev=7 --match 'v[0-9]*.*'`} webpack serve --env htmlTemplate=./base.html --config ./webpack.config.dev.js",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

confirmed on local

when evidence
directly set customized PIPECD_VERSION value at build/web
PIPECD_VERSION=v1-customized_web_version yarn --cwd web build
image
remove PIPECD_VERSION at build/web
yarn --cwd web build
note: -dirty appeared because Makefile is changed
image

@linhdangduy
Copy link
Contributor Author

@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 🙇🏼

Comment on lines +95 to +96
build-args: |
BUILD_VERSION=${{ env.PIPECD_VERSION }}
Copy link
Contributor Author

@linhdangduy linhdangduy Sep 28, 2025

Choose a reason for hiding this comment

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

confirmed the bug that happened on github action for the previous v0.54.0 build. For example

build image
piped image
launcher image

Expected that all of them will be fixed by this arg passing

@linhdangduy linhdangduy requested a review from Warashi September 29, 2025 01:11
Copy link
Member

@Warashi Warashi left a comment

Choose a reason for hiding this comment

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

Thank you!

There are arguments/variables named BUILD_VERSION and PIPECD_VERSION with the similar meaning. It's a bit confusing, so I want to use only either of them.

Makefile Outdated
run/pipecd: BUILD_LDFLAGS_PREFIX := -X github.com/pipe-cd/pipecd/pkg/version
run/pipecd: BUILD_OPTS ?= -ldflags "$(BUILD_LDFLAGS_PREFIX).version=$(BUILD_VERSION) $(BUILD_LDFLAGS_PREFIX).gitCommit=$(BUILD_COMMIT) $(BUILD_LDFLAGS_PREFIX).buildDate=$(BUILD_DATE) -w"
run/pipecd: CONTROL_PLANE_VALUES ?= ./quickstart/control-plane-values.yaml
run/pipecd: PIPECD_VERSION ?= $(shell git describe --tags --always --dirty --abbrev=7 --match 'v[0-9]*.*')
Copy link
Member

Choose a reason for hiding this comment

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

I found the note below on L150-152. I think we can use BUILD_VERSION as --build-arg BUILD_VERSION=$(BUILD_VERSION) instead of defining PIPECD_VERSION

NOTE: previously git describe --tags was used to determine the version for running locally
However, this does not work on a forked branch, so the decision was made to hardcode at version 0.0.0
see: #4845

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Warashi Thanks for your comment.

I found the note below on L150-152. I think we can use BUILD_VERSION as --build-arg BUILD_VERSION=$(BUILD_VERSION) instead of defining PIPECD_VERSION

yeah, that is the reason I add PIPECD_VERSION here. Using the local BUILD_VERSION to pass to docker file is fine for me. I will fix it

There are arguments/variables named BUILD_VERSION and PIPECD_VERSION with the similar meaning. It's a bit confusing, so I want to use only either of them.

Understand your point. IMO, I prefer to use BUILD_VERSION than PIPECD_VERSION because: go backend code use BUILD_VERSION internally, and it is more general and can pass to any go build command (for pipectl / pided...)

But PIPECD_VERSION is also written in many places like:

So for now, there are 2 approaches:

  1. for the new code in the scope of PR, use the BUILD_VERSION variable, do not touch the existing place that have PIPECD_VERSION defined (and work on renaming later)
  2. OR change PIPECD_VERSION -> BUILD_VERSION as well

I'm thinking of going for first approach.
What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

@linhdangduy
Thank you for explaining.

I think it's good to going the first approach. Please doing so?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Sorry for late. I have unified the new code to BUILD_VERSION 🙇🏼

a570992
and ba6edda

Copy link
Contributor Author

@linhdangduy linhdangduy Oct 8, 2025

Choose a reason for hiding this comment

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

local web access via http://localhost:8080 would become like this
image

@linhdangduy linhdangduy force-pushed the web-generate-pipecd-version-based-only-on-web-folder branch from fe2c365 to 1639e54 Compare October 8, 2025 06:28
@linhdangduy linhdangduy force-pushed the web-generate-pipecd-version-based-only-on-web-folder branch from 1639e54 to ba6edda Compare October 8, 2025 06:30
@codecov
Copy link

codecov bot commented Oct 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.63%. Comparing base (738066c) to head (0bf18ef).

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.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@Warashi Warashi left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants