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

fix: allow running docker runner as non-root user #1646

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions pkg/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ func New(ctx context.Context, opts ...Option) (*Build, error) {
if err != nil {
return nil, fmt.Errorf("unable to create workspace dir: %w", err)
}
err = os.Chmod(tmpdir, 0o755)
if err != nil {
return nil, fmt.Errorf("unable to change permissions to workspace directory: %w", err)
}
b.WorkspaceDir = tmpdir
}

Expand Down Expand Up @@ -731,6 +735,10 @@ func (b *Build) BuildPackage(ctx context.Context) error {
if err != nil {
return fmt.Errorf("unable to make guest directory: %w", err)
}
err = os.Chmod(guestDir, 0o755)
if err != nil {
return fmt.Errorf("unable to change permissions to guest directory: %w", err)
}
b.GuestDir = guestDir

if b.Remove {
Expand Down Expand Up @@ -860,6 +868,11 @@ func (b *Build) BuildPackage(ctx context.Context) error {
// run any pipelines for subpackages
for _, sp := range b.Configuration.Subpackages {
sp := sp

if err := os.MkdirAll(filepath.Join(b.WorkspaceDir, melangeOutputDirName, sp.Name), 0o755); err != nil {
return err
}

if !b.isBuildLess() {
log.Infof("running pipeline for subpackage %s", sp.Name)

Expand All @@ -870,10 +883,6 @@ func (b *Build) BuildPackage(ctx context.Context) error {
}
}

if err := os.MkdirAll(filepath.Join(b.WorkspaceDir, melangeOutputDirName, sp.Name), 0o755); err != nil {
return err
}

// add the main package to the linter queue
lintTarget := linterTarget{
pkgName: sp.Name,
Expand Down
3 changes: 2 additions & 1 deletion pkg/build/pipelines/git-checkout.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ pipeline:

[ "$depth" = "-1" ] || depthflag="--depth=$depth"

workdir=$(mktemp -d)
workdir=$(mktemp -u)
mkdir $workdir
rcfile=$(mktemp)
mkdir -p "$dest"
dest_fullpath=$(realpath "$dest")
Expand Down
Loading