@@ -251,10 +251,28 @@ func runRebuild(ctx context.Context, supervisorClient *supervisor.SupervisorClie
251
251
return err
252
252
}
253
253
254
- // we don't pass context on purporse to handle graceful shutdown
255
- // and output all logs properly below
256
- runCmd := exec .Command (
257
- dockerPath ,
254
+ type mnte struct {
255
+ IsFile bool
256
+ Target string
257
+ Source string
258
+ Permission os.FileMode
259
+ }
260
+
261
+ prepareFS := []mnte {
262
+ {Source : "/workspace" },
263
+ {Source : "/.supervisor" },
264
+ {Source : "/ide" },
265
+ {Source : "/workspace/.gitpod-debug/.docker-root" , Target : "/workspace/.docker-root" , Permission : 0710 },
266
+ {Source : "/workspace/.gitpod-debug/.gitpod" , Target : "/workspace/.gitpod" , Permission : 0751 },
267
+ {Source : "/workspace/.gitpod-debug/.vscode-remote" , Target : "/workspace/.vscode-remote" , Permission : 0751 },
268
+ {Source : "/workspace/.gitpod-debug/.cache" , Target : "/workspace/.cache" , Permission : 0751 },
269
+ {Source : "/workspace/.gitpod-debug/.config" , Target : "/workspace/.config" , Permission : 0751 },
270
+ {Source : "/usr/bin/docker-up" , IsFile : true },
271
+ {Source : "/usr/bin/runc-facade" , IsFile : true },
272
+ {Source : "/usr/local/bin/docker-compose" , IsFile : true },
273
+ }
274
+
275
+ dockerArgs := []string {
258
276
"run" ,
259
277
"--rm" ,
260
278
"--user" , "root" ,
@@ -268,17 +286,42 @@ func runRebuild(ctx context.Context, supervisorClient *supervisor.SupervisorClie
268
286
"-p" , "25001:23001" , // SSH
269
287
// 23002 dekstop IDE port, but it is covered by debug workspace proxy
270
288
"-p" , "25003:23003" , // debug workspace proxy
289
+ }
271
290
272
- // volumes
273
- "-v" , "/workspace:/workspace" ,
274
- "-v" , "/.supervisor:/.supervisor" ,
275
- "-v" , "/var/run/docker.sock:/var/run/docker.sock" ,
276
- "-v" , "/ide:/ide" ,
277
- // "-v", "/ide-desktop:/ide-desktop", // TODO fix desktop IDEs later
278
- // "-v", "/ide-desktop-plugins:/ide-desktop-plugins", // TODO refactor to keep all IDE deps under ide or ide-desktop
291
+ for _ , mnt := range prepareFS {
292
+ fd , err := os .Stat (mnt .Source )
293
+ if err != nil {
294
+ if ! os .IsNotExist (err ) {
295
+ return err
296
+ }
297
+ if mnt .IsFile {
298
+ return err
299
+ }
300
+ err = os .MkdirAll (mnt .Source , mnt .Permission )
301
+ if err != nil {
302
+ return err
303
+ }
304
+ fd , err = os .Stat (mnt .Source )
305
+ if err != nil {
306
+ return err
307
+ }
308
+ }
309
+ if fd .IsDir () != ! mnt .IsFile {
310
+ return xerrors .Errorf ("invalid file type for %s" , mnt .Source )
311
+ }
312
+ if mnt .Target == "" {
313
+ mnt .Target = mnt .Source
314
+ }
315
+ dockerArgs = append (dockerArgs , "-v" , fmt .Sprintf ("%s:%s" , mnt .Source , mnt .Target ))
316
+ }
279
317
280
- image ,
281
- "/.supervisor/supervisor" , "init" ,
318
+ dockerArgs = append (dockerArgs , image , "/.supervisor/supervisor" , "init" )
319
+
320
+ // we don't pass context on purporse to handle graceful shutdown
321
+ // and output all logs properly below
322
+ runCmd := exec .Command (
323
+ dockerPath ,
324
+ dockerArgs ... ,
282
325
)
283
326
284
327
debugSupervisor , err := supervisor .New (ctx , & supervisor.SupervisorClientOption {
0 commit comments