@@ -7,12 +7,20 @@ import {
77 argument ,
88 Secret ,
99 File ,
10- type Platform ,
1110} from "@dagger.io/dagger" ;
1211
1312const NODE_IMAGE = "node:24" ;
1413const RUST_IMAGE = "rust:bookworm" ;
1514
15+ // See https://github.com/rust-cross/rust-musl-cross?tab=readme-ov-file#prebuilt-images
16+ const TARGET_IMAGE_MAP = {
17+ "x86_64-unknown-linux-musl" : "ghcr.io/rust-cross/rust-musl-cross:x86_64-musl" ,
18+ "aarch64-unknown-linux-musl" :
19+ "ghcr.io/rust-cross/rust-musl-cross:aarch64-musl" ,
20+ "armv7-unknown-linux-musleabihf" :
21+ "ghcr.io/rust-cross/rust-musl-cross:armv7-musleabihf" ,
22+ } as const ;
23+
1624@object ( )
1725export class AtomicServer {
1826 source : Directory ;
@@ -198,18 +206,7 @@ export class AtomicServer {
198206 const source = this . source ;
199207 const cargoCache = dag . cacheVolume ( "cargo" ) ;
200208
201- let image = RUST_IMAGE ;
202- if ( target === "x86_64-unknown-linux-musl" ) {
203- image = "ghcr.io/rust-cross/rust-musl-cross:x86_64-musl" ;
204- } else if ( target === "aarch64-unknown-linux-musl" ) {
205- image = "ghcr.io/rust-cross/rust-musl-cross:aarch64-musl" ;
206- } else if ( target === "armv7-unknown-linux-musleabihf" ) {
207- image = "ghcr.io/rust-cross/rust-musl-cross:armv7-musleabihf" ;
208- } else {
209- throw new Error (
210- `Unknown target: ${ target } . Supported targets are: x86_64-unknown-linux-musl, aarch64-unknown-linux-musl, armv7-unknown-linux-musleabihf.`
211- ) ;
212- }
209+ const image = TARGET_IMAGE_MAP [ target as keyof typeof TARGET_IMAGE_MAP ] ;
213210
214211 const rustContainer = dag
215212 . container ( )
@@ -502,14 +499,9 @@ export class AtomicServer {
502499 }
503500
504501 @func ( )
505- async releaseAssets (
506- @argument ( )
507- targets : string [ ] = [
508- "x86_64-unknown-linux-musl" ,
509- "aarch64-unknown-linux-musl" ,
510- "armv7-unknown-linux-musleabihf" ,
511- ]
512- ) : Promise < Directory > {
502+ async releaseAssets ( ) : Promise < Directory > {
503+ const targets = Object . keys ( TARGET_IMAGE_MAP ) ;
504+
513505 const builds = targets . map ( ( target ) => {
514506 const container = this . rustBuild ( true , target ) ;
515507 return {
0 commit comments