Skip to content

[FrameworkBundle] Split "var/build" from "var/cache" when compiling for the "prod" env #57556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Jun 27, 2024

Q A
Branch? 7.2
Bug fix? no
New feature? yes
Deprecations? no
Issues -
License MIT

I think it's time to consider defaulting to having separate build vs cache folders.
#50391 opened the way, then @Okhoshi continued it in #52962, #52981, #54384, with a tweak in #57553.

I know that doing this change will improve the DX of deploying on Platform.sh: the container compilation happening during the offline generation of the container image will be reusable right away, without any step to copy the related artifacts in a writeable folder. I'm confident this can benefit other hosting systems too.

Let's have this discussion and figure out any blockers.

Comment on lines +124 to +126
if ('prod' === $this->getEnvironment() && Kernel::class === (new \ReflectionMethod(parent::class, 'getCacheDir'))->class) {
return $this->getProjectDir().'/var/build/'.$this->environment;
}
Copy link
Contributor

@ro0NL ro0NL Jun 27, 2024

Choose a reason for hiding this comment

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

it feels a bit dirty ... what about a new (temporary?) configuration env? to be used upstream:

// Returns $this->getCacheDir() for backward compatibility
return $this->getCacheDir();

which brings me to; can we get rid of the parent calls in a trait, by making the envs defacto config envs

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't understand your proposal sorry (nor its "why"). Please expand if you want.

Copy link
Contributor

Choose a reason for hiding this comment

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

e.g. APP_USE_BUILD_DIR=1 so we dont hardcode the prod env and rely on reflection

also im wondering handling the APP_ envs like APP_CACHE_DIR can be dealt with in Kernel as a firt clas feature

Copy link
Member Author

Choose a reason for hiding this comment

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

An alternative implementation might be to define APP_BUILD_DIR in .env.prod in a recipe.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 i tend to prefer a pure configuration solution

but isnt the bigger goal to eventually swap the current implementation?

public function getBuildDir(): string
{
// Returns $this->getCacheDir() for backward compatibility
return $this->getCacheDir();
}

@nicolas-grekas nicolas-grekas deleted the build-dir branch August 13, 2024 09:13
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