@@ -241,10 +241,28 @@ func runRebuild(ctx context.Context, supervisorClient *supervisor.SupervisorClie
241
241
return err
242
242
}
243
243
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 ,
244
+ type mnte struct {
245
+ IsFile bool
246
+ Target string
247
+ Source string
248
+ Permission os.FileMode
249
+ }
250
+
251
+ prepareFS := []mnte {
252
+ {Source : "/workspace" },
253
+ {Source : "/.supervisor" },
254
+ {Source : "/ide" },
255
+ {Source : "/workspace/.gitpod-debug/.docker-root" , Target : "/workspace/.docker-root" , Permission : 0710 },
256
+ {Source : "/workspace/.gitpod-debug/.gitpod" , Target : "/workspace/.gitpod" , Permission : 0751 },
257
+ {Source : "/workspace/.gitpod-debug/.vscode-remote" , Target : "/workspace/.vscode-remote" , Permission : 0751 },
258
+ {Source : "/workspace/.gitpod-debug/.cache" , Target : "/workspace/.cache" , Permission : 0751 },
259
+ {Source : "/workspace/.gitpod-debug/.config" , Target : "/workspace/.config" , Permission : 0751 },
260
+ {Source : "/usr/bin/docker-up" , IsFile : true },
261
+ {Source : "/usr/bin/runc-facade" , IsFile : true },
262
+ {Source : "/usr/local/bin/docker-compose" , IsFile : true },
263
+ }
264
+
265
+ dockerArgs := []string {
248
266
"run" ,
249
267
"--rm" ,
250
268
"--user" , "root" ,
@@ -258,17 +276,38 @@ func runRebuild(ctx context.Context, supervisorClient *supervisor.SupervisorClie
258
276
"-p" , "25001:23001" , // SSH
259
277
// 23002 dekstop IDE port, but it is covered by debug workspace proxy
260
278
"-p" , "25003:23003" , // debug workspace proxy
279
+ }
261
280
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
281
+ for _ , mnt := range prepareFS {
282
+ fd , err := os .Stat (mnt .Source )
283
+ if err != nil {
284
+ if ! os .IsNotExist (err ) {
285
+ return err
286
+ }
287
+ if mnt .IsFile {
288
+ return err
289
+ }
290
+ err = os .MkdirAll (mnt .Source , mnt .Permission )
291
+ if err != nil {
292
+ return err
293
+ }
294
+ }
295
+ if fd .IsDir () != ! mnt .IsFile {
296
+ return xerrors .Errorf ("invalid file type for %s" , mnt .Source )
297
+ }
298
+ if mnt .Target == "" {
299
+ mnt .Target = mnt .Source
300
+ }
301
+ dockerArgs = append (dockerArgs , "-v" , fmt .Sprintf ("%s:%s" , mnt .Source , mnt .Target ))
302
+ }
269
303
270
- image ,
271
- "/.supervisor/supervisor" , "init" ,
304
+ dockerArgs = append (dockerArgs , image , "/.supervisor/supervisor" , "init" )
305
+
306
+ // we don't pass context on purporse to handle graceful shutdown
307
+ // and output all logs properly below
308
+ runCmd := exec .Command (
309
+ dockerPath ,
310
+ dockerArgs ... ,
272
311
)
273
312
274
313
debugSupervisor , err := supervisor .New (ctx , & supervisor.SupervisorClientOption {
0 commit comments