@@ -271,17 +271,58 @@ export class AtomicServer {
271
271
@func ( )
272
272
rustCrossBuild ( @argument ( ) target : string ) : Container {
273
273
const source = this . source ;
274
+ const cargoCache = dag . cacheVolume ( "cargo" ) ;
275
+
276
+ // Use rust-musl-cross images which support multi-arch builds
277
+ // Map target to the appropriate image tag
278
+ let imageTag : string ;
279
+ switch ( target ) {
280
+ case "x86_64-unknown-linux-musl" :
281
+ imageTag = "x86_64-musl" ;
282
+ break ;
283
+ case "aarch64-unknown-linux-musl" :
284
+ imageTag = "aarch64-musl" ;
285
+ break ;
286
+ case "armv7-unknown-linux-musleabihf" :
287
+ imageTag = "armv7-musleabihf" ;
288
+ break ;
289
+ default :
290
+ throw new Error ( `Unsupported cross-compilation target: ${ target } ` ) ;
291
+ }
292
+
274
293
const rustContainer = dag
275
294
. container ( )
276
- . from ( RUST_IMAGE )
277
- . withExec ( [ "cargo" , "install" , "cross" ] )
278
- . withMountedDirectory ( "/code" , source )
279
- . withWorkdir ( "/code" )
280
- . withExec ( [ "rustup" , "target" , "add" , target ] ) ;
295
+ . from ( `ghcr.io/rust-cross/rust-musl-cross:${ imageTag } ` )
296
+ . withExec ( [ "apt-get" , "update" , "-qq" ] )
297
+ . withExec ( [ "apt-get" , "install" , "-y" , "nasm" ] )
298
+ . withMountedCache ( "/home/rust/.cargo/registry" , cargoCache ) ;
281
299
282
- return rustContainer
283
- . withExec ( [ "cross" , "build" , "--target" , target , "--release" ] )
284
- . withExec ( [ `./target/${ target } /release/atomic-server` , "--version" ] ) ;
300
+ const sourceContainer = rustContainer
301
+ . withFile ( "/home/rust/src/Cargo.toml" , source . file ( "Cargo.toml" ) )
302
+ . withFile ( "/home/rust/src/Cargo.lock" , source . file ( "Cargo.lock" ) )
303
+ . withDirectory ( "/home/rust/src/server" , source . directory ( "server" ) )
304
+ . withDirectory ( "/home/rust/src/lib" , source . directory ( "lib" ) )
305
+ . withDirectory ( "/home/rust/src/cli" , source . directory ( "cli" ) )
306
+ . withMountedCache ( "/home/rust/src/target" , dag . cacheVolume ( "rust-target" ) )
307
+ . withWorkdir ( "/home/rust/src" )
308
+ . withExec ( [ "cargo" , "fetch" ] ) ;
309
+
310
+ // Include frontend assets for the server build
311
+ const browserDir = this . jsBuild ( ) . directory ( "/app/data-browser/dist" ) ;
312
+ const containerWithAssets = sourceContainer . withDirectory (
313
+ "/home/rust/src/server/assets_tmp" ,
314
+ browserDir
315
+ ) ;
316
+
317
+ // Build using the pre-configured cross-compilation environment
318
+ return containerWithAssets
319
+ . withExec ( [ "cargo" , "build" , "--target" , target , "--release" ] )
320
+ . withExec ( [ `./target/${ target } /release/atomic-server` , "--version" ] )
321
+ . withExec ( [
322
+ "cp" ,
323
+ `./target/${ target } /release/atomic-server` ,
324
+ "/atomic-server-binary" ,
325
+ ] ) ;
285
326
}
286
327
287
328
@func ( )
@@ -378,9 +419,7 @@ export class AtomicServer {
378
419
const crossBuildContainer = this . rustCrossBuild (
379
420
"x86_64-unknown-linux-musl"
380
421
) ;
381
- const binaryFile = crossBuildContainer . file (
382
- "/code/target/x86_64-unknown-linux-musl/release/atomic-server"
383
- ) ;
422
+ const binaryFile = crossBuildContainer . file ( "/atomic-server-binary" ) ;
384
423
385
424
// Create deployment container with SSH client
386
425
const deployContainer = dag
@@ -431,24 +470,4 @@ export class AtomicServer {
431
470
432
471
return `Deployment to ${ remoteHost } completed successfully:\n${ deployResult } ` ;
433
472
}
434
-
435
- @func ( )
436
- async deployStaging (
437
- @argument ( ) remoteUser : Secret ,
438
- @argument ( ) sshPrivateKey : Secret
439
- ) : Promise < string > {
440
- return this . deployServer (
441
- "staging.atomicdata.dev" ,
442
- remoteUser ,
443
- sshPrivateKey
444
- ) ;
445
- }
446
-
447
- @func ( )
448
- async deployProduction (
449
- @argument ( ) remoteUser : Secret ,
450
- @argument ( ) sshPrivateKey : Secret
451
- ) : Promise < string > {
452
- return this . deployServer ( "atomicdata.dev" , remoteUser , sshPrivateKey ) ;
453
- }
454
473
}
0 commit comments