Skip to content
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

Enable GID override in Build #1041

Closed
wants to merge 1 commit into from
Closed

Conversation

jsncmgs1
Copy link
Contributor

@jsncmgs1 jsncmgs1 commented Jan 26, 2021

Summary

Allows group ID to be set via a -gid flag.
#961

Output

Before

After

Documentation

  • Should this change be documented?
    • Yes, see #___
    • No

Related

Resolves #961

@github-actions github-actions bot added this to the 0.17.0 milestone Jan 26, 2021
@github-actions github-actions bot added the type/enhancement Issue that requests a new feature or improvement. label Jan 26, 2021
@jsncmgs1
Copy link
Contributor Author

jsncmgs1 commented Jan 26, 2021

I think I'm close here (minus test changes and additions), but I could use a nudge in the right direction on this.

So far I've added the flag and a type representing the flag, and I pass the flag value down into builder.userAndGroupIDs, overriding the value set on CNB_GROUP_ID.

When I run this locally, it picks up the group ID change for /layers, but not /workspace:

$ out/pack build test_img --path ../go_stuff --builder heroku/buildpacks:18 --gid=3 --pull-policy if-not-present

Screen Shot 2021-01-26 at 4 30 26 PM

I'm having some trouble locating where I need to make the change for the /workspace group ID and prevent the change for /layers. I think they're created here?

for _, path := range []string{workspaceDir, layersDir} {

But it seems like at some point /app is copied or symlinked into /workspace. Any help is appreciated :)

@dfreilich
Copy link
Member

@jsncmgs1 Thanks for the PR and work on it! Your path right now seems to be changing the user environment of the ephemeral builder, which is definitely interesting! What I'd recommend is rather than changing the builder, pass the gid argument (if provided) to the relevant lifecycle phases (analyze, restore, export, and create). You can see examples of how we pass flags to the lifecycle phases here (in internal/build/lifecycle_execution.go):

flags := addTags([]string{
"-cache-dir", l.mountPaths.cacheDir(),
"-run-image", runImage,
}, additionalTags)
if clearCache {
flags = append(flags, "-skip-restore")
}
processType := determineDefaultProcessType(l.platformAPI, l.opts.DefaultProcessType)
if processType != "" {
flags = append(flags, "-process-type", processType)
}
var cacheOpts PhaseConfigProviderOperation
switch buildCache.Type() {
case cache.Image:
flags = append(flags, "-cache-image", buildCache.Name())
cacheOpts = WithBinds(volumes...)
case cache.Volume:
cacheOpts = WithBinds(append(volumes, fmt.Sprintf("%s:%s", buildCache.Name(), l.mountPaths.cacheDir()))...)
}

@dfreilich dfreilich changed the title wip Enable GID override in Build Feb 8, 2021
@jsncmgs1 jsncmgs1 closed this Feb 16, 2021
@jsncmgs1 jsncmgs1 deleted the issues/961 branch February 16, 2021 17:44
@dfreilich
Copy link
Member

Hey @jsncmgs1 - let me know if I can be of help with this (assuming you're still interested). The fix for this would be similar to what's being done in #988, I'd be happy to walk through it with you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Issue that requests a new feature or improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add -gid Flag to Pack to Support OpenShift
2 participants