@@ -11,7 +11,6 @@ import (
11
11
"fmt"
12
12
"io"
13
13
"io/fs"
14
- "log"
15
14
"maps"
16
15
"net"
17
16
"net/http"
@@ -343,21 +342,6 @@ func Run(ctx context.Context, options Options) error {
343
342
}
344
343
}
345
344
346
- if options .PushImage {
347
- // Copy the envbuilder binary into the build context.
348
- buildParams .DockerfileContent = buildParams .DockerfileContent + "\n " +
349
- fmt .Sprintf ("COPY %s %s" , ".envbuilder" , "/.envbuilder" )
350
-
351
- log .Println ("FIXME show me the Dockerfile now: " + buildParams .DockerfileContent )
352
-
353
- binPath := filepath .Join (MagicDir , "bin" , "envbuilder" )
354
- dst := filepath .Join (buildParams .BuildContext , binPath )
355
- err := copyFile (binPath , dst )
356
- if err != nil {
357
- return fmt .Errorf ("aaa : %v" , err )
358
- }
359
- }
360
-
361
345
HijackLogrus (func (entry * logrus.Entry ) {
362
346
for _ , line := range strings .Split (entry .Message , "\r " ) {
363
347
options .Logger (notcodersdk .LogLevelInfo , "#%d: %s" , stageNumber , color .HiBlackString (line ))
@@ -421,9 +405,29 @@ func Run(ctx context.Context, options Options) error {
421
405
util .AddToDefaultIgnoreList (util.IgnoreListEntry {
422
406
Path : ignorePath ,
423
407
PrefixMatchOnly : false ,
408
+ AllowedPaths : map [string ]struct {}{},
424
409
})
425
410
}
426
411
412
+ // In order to allow 'resuming' envbuilder, embed the binary into the image
413
+ // if it is being pushed
414
+ if options .PushImage {
415
+ exePath , err := os .Executable ()
416
+ if err != nil {
417
+ return xerrors .Errorf ("get exe path: %w" , err )
418
+ }
419
+ // Add an exception for the current running binary in kaniko ignore list
420
+ if err := util .AddAllowedPathToDefaultIgnoreList (exePath ); err != nil {
421
+ return xerrors .Errorf ("add exe path to ignore list: %w" , err )
422
+ }
423
+ // Copy the envbuilder binary into the build context.
424
+ buildParams .DockerfileContent += fmt .Sprintf ("\n COPY %s %s" , exePath , exePath )
425
+ dst := filepath .Join (buildParams .BuildContext , exePath )
426
+ if err := copyFile (exePath , dst ); err != nil {
427
+ return xerrors .Errorf ("copy running binary to build context: %w" , err )
428
+ }
429
+ }
430
+
427
431
// temp move of all ro mounts
428
432
tempRemountDest := filepath .Join ("/" , MagicDir , "mnt" )
429
433
ignorePrefixes := []string {tempRemountDest , "/proc" , "/sys" }
0 commit comments