@@ -20,6 +20,7 @@ import (
20
20
"github.com/gitpod-io/gitpod/common-go/log"
21
21
"github.com/gitpod-io/gitpod/gitpod-cli/pkg/supervisor"
22
22
"github.com/gitpod-io/gitpod/gitpod-cli/pkg/utils"
23
+ "github.com/pkg/errors"
23
24
"github.com/sirupsen/logrus"
24
25
"github.com/spf13/cobra"
25
26
"golang.org/x/xerrors"
@@ -241,10 +242,28 @@ func runRebuild(ctx context.Context, supervisorClient *supervisor.SupervisorClie
241
242
return err
242
243
}
243
244
244
- // we don't pass context on purporse to handle graceful shutdown
245
- // and output all logs properly below
246
- runCmd := exec .Command (
247
- dockerPath ,
245
+ type mnte struct {
246
+ IsFile bool
247
+ Target string
248
+ Source string
249
+ Permission os.FileMode
250
+ }
251
+
252
+ prepareFS := []mnte {
253
+ {Source : "/workspace" },
254
+ {Source : "/.supervisor" },
255
+ {Source : "/ide" },
256
+ {Source : "/workspace/.gitpod-debug/.docker-root" , Target : "/workspace/.docker-root" , Permission : 0710 },
257
+ {Source : "/workspace/.gitpod-debug/.gitpod" , Target : "/workspace/.gitpod" , Permission : 0751 },
258
+ {Source : "/workspace/.gitpod-debug/.vscode-remote" , Target : "/workspace/.vscode-remote" , Permission : 0751 },
259
+ {Source : "/workspace/.gitpod-debug/.cache" , Target : "/workspace/.cache" , Permission : 0751 },
260
+ {Source : "/workspace/.gitpod-debug/.config" , Target : "/workspace/.config" , Permission : 0751 },
261
+ {Source : "/usr/bin/docker-up" , IsFile : true },
262
+ {Source : "/usr/bin/runc-facade" , IsFile : true },
263
+ {Source : "/usr/local/bin/docker-compose" , IsFile : true },
264
+ }
265
+
266
+ dockerArgs := []string {
248
267
"run" ,
249
268
"--rm" ,
250
269
"--user" , "root" ,
@@ -258,17 +277,35 @@ func runRebuild(ctx context.Context, supervisorClient *supervisor.SupervisorClie
258
277
"-p" , "25001:23001" , // SSH
259
278
// 23002 dekstop IDE port, but it is covered by debug workspace proxy
260
279
"-p" , "25003:23003" , // debug workspace proxy
280
+ }
281
+
282
+ for _ , mnt := range prepareFS {
283
+ fd , err := os .Stat (mnt .Source )
284
+ if err != nil {
285
+ if ! os .IsNotExist (err ) {
286
+ return err
287
+ }
288
+ if mnt .IsFile {
289
+ return err
290
+ }
291
+ err = os .MkdirAll (mnt .Source , mnt .Permission )
292
+ if err != nil {
293
+ return err
294
+ }
295
+ }
296
+ if fd .IsDir () != ! mnt .IsFile {
297
+ return errors .Errorf ("invalid file type for %s" , mnt .Source )
298
+ }
299
+ dockerArgs = append (dockerArgs , "-v" , fmt .Sprintf ("%s:%s" , mnt .Source , mnt .Target ))
300
+ }
261
301
262
- // volumes
263
- "-v" , "/workspace:/workspace" ,
264
- "-v" , "/.supervisor:/.supervisor" ,
265
- "-v" , "/var/run/docker.sock:/var/run/docker.sock" ,
266
- "-v" , "/ide:/ide" ,
267
- // "-v", "/ide-desktop:/ide-desktop", // TODO fix desktop IDEs later
268
- // "-v", "/ide-desktop-plugins:/ide-desktop-plugins", // TODO refactor to keep all IDE deps under ide or ide-desktop
302
+ dockerArgs = append (dockerArgs , image , "/.supervisor/supervisor" , "init" )
269
303
270
- image ,
271
- "/.supervisor/supervisor" , "init" ,
304
+ // we don't pass context on purporse to handle graceful shutdown
305
+ // and output all logs properly below
306
+ runCmd := exec .Command (
307
+ dockerPath ,
308
+ dockerArgs ... ,
272
309
)
273
310
274
311
debugSupervisor , err := supervisor .New (ctx , & supervisor.SupervisorClientOption {
0 commit comments