diff --git a/images/basic/rust/Cargo.toml b/images/basic/rust/Cargo.toml new file mode 100644 index 000000000..c759dfb72 --- /dev/null +++ b/images/basic/rust/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "hello-world" +version = "0.1.0" + +[[bin]] +name = "hello-world" +path = "helloworld.rs" \ No newline at end of file diff --git a/images/basic/rust/Dockerfile b/images/basic/rust/Dockerfile new file mode 100644 index 000000000..47155bcd7 --- /dev/null +++ b/images/basic/rust/Dockerfile @@ -0,0 +1,12 @@ +FROM rust:1.75.0 +# Set the working directory +WORKDIR /app + +# Copy the application files into the image +COPY Cargo.toml helloworld.rs ./ + +# Build the application in release mode +RUN cargo build --release + +# Set the command to run the binary +CMD ["./target/release/hello-world"] \ No newline at end of file diff --git a/images/basic/rust/helloworld.rs b/images/basic/rust/helloworld.rs new file mode 100644 index 000000000..0672e5106 --- /dev/null +++ b/images/basic/rust/helloworld.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, World!"); +} diff --git a/test/image/image_test.go b/test/image/image_test.go index 6be773c52..1d5d61f42 100644 --- a/test/image/image_test.go +++ b/test/image/image_test.go @@ -64,6 +64,25 @@ func TestHelloWorld(t *testing.T) { } } +func TestRust(t *testing.T) { + ctx := context.Background() + d := dockerutil.MakeContainer(ctx, t) + defer d.CleanUp(ctx) + + // Run the basic container. + out, err := d.Run(ctx, dockerutil.RunOpts{ + Image: "basic/rust", + }) + if err != nil { + t.Fatalf("docker run failed: %v", err) + } + + // Check the output. + if !strings.Contains(out, "Hello, World!") { + t.Fatalf("Container didn't say Hello, World!: got %s", out) + } +} + func runHTTPRequest(ip string, port int) error { url := fmt.Sprintf("http://%s:%d/not-found", ip, port) resp, err := http.Get(url)