@@ -141,32 +141,19 @@ Update your application Dockerfile using one of the templates at https://github.
141141 return info ;
142142 }
143143
144- // creates a rootfs tarball from the image
145- // this process is not always fully reproducible
146- // FIXME: we could use the image and create a flat rootfs without
147- // `docker container create` (use undocker, umoci, a native typescript implementation, etc.)
144+ // saves the OCI Image to a tarball
148145 private async createTarball (
149146 image : string ,
150147 outputFilePath : string ,
151148 ) : Promise < void > {
152149 // create docker tarball from app image
153150 const { stdout : appCid } = await execa ( "docker" , [
154- "container" ,
155- "create" ,
156- "--platform" ,
157- "linux/riscv64" ,
151+ "image" ,
152+ "save" ,
158153 image ,
159- ] ) ;
160-
161- await execa ( "docker" , [
162- "container" ,
163- "export" ,
164154 "-o" ,
165155 outputFilePath ,
166- appCid ,
167156 ] ) ;
168-
169- await execa ( "docker" , [ "container" , "rm" , appCid ] ) ;
170157 }
171158
172159 // this wraps the call to the sdk image with a one-shot approach
@@ -201,15 +188,24 @@ Update your application Dockerfile using one of the templates at https://github.
201188 await execa ( "docker" , [ "container" , "rm" , cid ] ) ;
202189 }
203190
204- // returns the command to create rootfs from a tarball
191+ // returns the command to create rootfs tarball from an OCI Image tarball
205192 private static createRootfsTarCommand ( ) : string [ ] {
206- return [
193+ const cmd = [
194+ "cat" ,
195+ "/tmp/input" ,
196+ "|" ,
197+ "crane" ,
198+ "export" ,
199+ "-" , // OCI Image from stdin
200+ "-" , // rootfs tarball to stdout
201+ "|" ,
207202 "bsdtar" ,
208203 "-cf" ,
209204 "/tmp/output" ,
210205 "--format=gnutar" ,
211- "@/tmp/input" ,
206+ "@/dev/stdin" , // rootfs tarball from stdin
212207 ] ;
208+ return [ "/usr/bin/env" , "bash" , "-c" , cmd . join ( " " ) ] ;
213209 }
214210
215211 // returns the command to create ext2 from a rootfs
0 commit comments