dagger-runtime-benchmark/actions/upload.go

56 lines
1.3 KiB
Go
Raw Normal View History

2023-05-18 15:50:47 +02:00
package main
import (
"context"
"os"
"dagger.io/dagger"
)
func Upload(ctx context.Context) error {
client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stdout))
if err != nil {
return err
}
src := client.Host().
Directory("bench_app", dagger.HostDirectoryOpts{Exclude: []string{"target/"}})
rust_base := client.Container().
From("rustlang/rust:nightly").
WithDirectory("/mnt/app", src).
WithWorkdir("/mnt/app").
WithExec([]string{"cargo", "build", "--release"})
rust_binary := rust_base.File("target/release/bench_app")
rust_application_image := client.Container().
From("alpine").
WithFile("/usr/bin/bench_app", rust_binary)
wasm_binary := client.Container().
From("rustlang/rust:nightly").
WithExec([]string{"rustup", "target", "add", "wasm32-wasi"}).
WithDirectory("/mnt/app", src).
WithWorkdir("/mnt/app").
WithExec([]string{"cargo", "build", "--release", "--target=wasm32-wasi"}).
File("target/wasm32-wasi/release/bench_app.wasm")
_, err = rust_binary.Export(ctx, "dist/binary/bench_app")
if err != nil {
return err
}
_, err = wasm_binary.Export(ctx, "dist/wasm/bench_app.wasm")
if err != nil {
return err
}
_, err = rust_application_image.Export(ctx, "dist/bench_app.tar.gz")
if err != nil {
return err
}
return nil
}