@@ -11,6 +11,7 @@ import (
11
11
"fmt"
12
12
"io"
13
13
"io/fs"
14
+ "log"
14
15
"maps"
15
16
"net"
16
17
"net/http"
@@ -27,7 +28,6 @@ import (
27
28
28
29
"github.com/kballard/go-shellquote"
29
30
"github.com/mattn/go-isatty"
30
- cp "github.com/otiai10/copy"
31
31
32
32
"github.com/GoogleContainerTools/kaniko/pkg/config"
33
33
"github.com/GoogleContainerTools/kaniko/pkg/creds"
@@ -345,13 +345,17 @@ func Run(ctx context.Context, options Options) error {
345
345
346
346
if options .PushImage {
347
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
+
348
353
binPath := filepath .Join (MagicDir , "bin" , "envbuilder" )
349
- err := cp .Copy (binPath , filepath .Join (buildParams .BuildContext , binPath ))
354
+ dst := filepath .Join (buildParams .BuildContext , binPath )
355
+ err := copyFile (binPath , dst )
350
356
if err != nil {
351
- return err
357
+ return fmt . Errorf ( "aaa : %v" , err )
352
358
}
353
- buildParams .DockerfileContent = buildParams .DockerfileContent + "\n " +
354
- "COPY " + binPath + " " + binPath
355
359
}
356
360
357
361
HijackLogrus (func (entry * logrus.Entry ) {
@@ -1171,3 +1175,21 @@ func maybeDeleteFilesystem(log LoggerFunc, force bool) error {
1171
1175
1172
1176
return util .DeleteFilesystem ()
1173
1177
}
1178
+
1179
+ func copyFile (src , dst string ) error {
1180
+ content , err := os .ReadFile (src )
1181
+ if err != nil {
1182
+ return xerrors .Errorf ("read file failed: %w" , err )
1183
+ }
1184
+
1185
+ err = os .MkdirAll (filepath .Dir (dst ), 0755 )
1186
+ if err != nil {
1187
+ return xerrors .Errorf ("mkdir all failed: %w" , err )
1188
+ }
1189
+
1190
+ err = os .WriteFile (dst , content , 0644 )
1191
+ if err != nil {
1192
+ return xerrors .Errorf ("write file failed: %w" , err )
1193
+ }
1194
+ return nil
1195
+ }
0 commit comments