From 3abef452fb45bdcdbe4291caeae1ebd1a12589e4 Mon Sep 17 00:00:00 2001 From: Ce Gao Date: Sat, 18 Jun 2022 19:19:31 +0800 Subject: [PATCH] fix: Fix the bug about uid (#447) Signed-off-by: Ce Gao --- pkg/lang/ir/compile.go | 5 +++++ pkg/lang/ir/system.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/lang/ir/compile.go b/pkg/lang/ir/compile.go index e53d7f176..0cae6effc 100644 --- a/pkg/lang/ir/compile.go +++ b/pkg/lang/ir/compile.go @@ -21,6 +21,7 @@ import ( "github.com/cockroachdb/errors" "github.com/moby/buildkit/client/llb" + "github.com/sirupsen/logrus" "github.com/tensorchord/envd/pkg/progress/compileui" "github.com/tensorchord/envd/pkg/types" @@ -121,6 +122,10 @@ func (g Graph) Compile(uid, gid int) (llb.State, error) { // TODO(gaocegege): Remove the hack for https://github.com/tensorchord/envd/issues/370 g.gid = 1001 + logrus.WithFields(logrus.Fields{ + "uid": g.uid, + "gid": g.gid, + }).Debug("compile LLB") // TODO(gaocegege): Support more OS and langs. base := g.compileBase() diff --git a/pkg/lang/ir/system.go b/pkg/lang/ir/system.go index 9da833a7f..c4fa2ea65 100644 --- a/pkg/lang/ir/system.go +++ b/pkg/lang/ir/system.go @@ -114,7 +114,7 @@ func (g *Graph) compileBase() llb.State { res := base. Run(llb.Shlex(fmt.Sprintf("groupadd -g %d envd", g.gid)), llb.WithCustomName("[internal] create user group envd")). - Run(llb.Shlex(fmt.Sprintf("useradd -p \"\" -u %d -g envd -s /bin/sh -m envd", g.gid)), + Run(llb.Shlex(fmt.Sprintf("useradd -p \"\" -u %d -g envd -s /bin/sh -m envd", g.uid)), llb.WithCustomName("[internal] create user envd")). Run(llb.Shlex("adduser envd sudo"), llb.WithCustomName("[internal] add user envd to sudoers")).