@@ -127,13 +127,16 @@ export class Install {
127127 const cli = await HubRepository . build ( 'dockereng/cli-bin' ) ;
128128 extractFolder = await cli . extractImage ( tag ) ;
129129
130- // Daemon is only available for Windows and Linux
131- if ( [ 'win32' , 'linux' ] . includes ( platform ) ) {
130+ if ( [ 'win32' , 'linux' , 'darwin' ] . includes ( platform ) ) {
132131 core . info ( `Downloading dockerd from moby/moby-bin:${ tag } ` ) ;
133132 const moby = await HubRepository . build ( 'moby/moby-bin' ) ;
134- await moby . extractImage ( tag , extractFolder ) ;
133+
134+ // On macOS, we extract the Linux version of dockerd which will be run in a lima VM.
135+ const extractPlatform = platform == 'darwin' ? 'linux' : undefined ;
136+
137+ await moby . extractImage ( tag , extractFolder , extractPlatform ) ;
135138 } else {
136- core . info ( `dockerd not supported on ${ platform } ` ) ;
139+ core . warning ( `dockerd not supported on ${ platform } , only the Docker cli will be available ` ) ;
137140 }
138141 break ;
139142 }
@@ -192,14 +195,19 @@ export class Install {
192195 }
193196
194197 private async installDarwin ( ) : Promise < string > {
195- if ( this . source . type !== 'archive' ) {
196- throw new Error ( 'Only archive source is supported on macOS' ) ;
197- }
198- const src = this . source as InstallSourceArchive ;
198+ const src = this . source ;
199199 const limaDir = path . join ( os . homedir ( ) , '.lima' , this . limaInstanceName ) ;
200200 await io . mkdirP ( limaDir ) ;
201201 const dockerHost = `unix://${ limaDir } /docker.sock` ;
202202
203+ // this.toolDir is a very long path which causes trouble when mounting it in lima.
204+ // Copy it to a shorter path.
205+ const limaToolsDir = path . join ( os . homedir ( ) , 'tools-' + this . _version ) ;
206+
207+ await core . group ( 'Copy tools' , async ( ) => {
208+ await Exec . exec ( 'cp' , [ '-rv' , this . toolDir , limaToolsDir ] ) ;
209+ } ) ;
210+
203211 // avoid brew to auto update and upgrade unrelated packages.
204212 let envs = Object . assign ( { } , process . env , {
205213 HOMEBREW_NO_AUTO_UPDATE : '1' ,
@@ -226,12 +234,16 @@ export class Install {
226234 handlebars . registerHelper ( 'stringify' , function ( obj ) {
227235 return new handlebars . SafeString ( JSON . stringify ( obj ) ) ;
228236 } ) ;
237+ const srcArchive = src as InstallSourceArchive ;
229238 const limaCfg = handlebars . compile ( limaYamlData ) ( {
230239 customImages : Install . limaCustomImages ( ) ,
231240 daemonConfig : limaDaemonConfig ,
232241 dockerSock : `${ limaDir } /docker.sock` ,
233- dockerBinVersion : src . version . replace ( / ^ v / , '' ) ,
234- dockerBinChannel : src . channel
242+ srcType : src . type ,
243+ srcArchiveVersion : srcArchive . version ?. replace ( / ^ v / , '' ) ,
244+ srcArchiveChannel : srcArchive . channel ,
245+ srcImageTag : ( src as InstallSourceImage ) . tag ,
246+ toolDir : limaToolsDir
235247 } ) ;
236248 core . info ( `Writing lima config to ${ path . join ( limaDir , 'lima.yaml' ) } ` ) ;
237249 fs . writeFileSync ( path . join ( limaDir , 'lima.yaml' ) , limaCfg ) ;
0 commit comments