Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Table of Contents:
| **[Terraform NGINX hello world](containers/terraform-nginx-hello-world/README.md)** <br/> A minimal example running the base NGINX image in a serverless container deployed with Terraform. | N/A | [Terraform] |
| **[Triggers with Terraform](containers/terraform-triggers/README.md)** <br/> Configuring two SQS triggers, used to trigger two containers, one public, one private. | N/A | [Terraform] |
| **[gRPC HTTP2 in Go](containers/grpc-http2-go/README.md)** <br/> A Go gRPC Container using http2 | Go/Protobuf | [CLI] |
| **[Rust hello world](containers/rust-hello-world)** <br/> A simple Rust hello world Container | Rust | [CLI] |
| **[.NET C#](containers/csharp-hello-world)** <br/> A .NET C# Container hello world | C# .NET | [CLI] |
| **[Ruby Hello World](containers/ruby-hello-world/)** <br/> A simple Ruby Hello world Container | Ruby | [CLI] |

Expand Down
2 changes: 1 addition & 1 deletion containers/rust-hello-world/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hello-world"
version = "0.1.0"
edition = "2021"
edition = "2024"

[dependencies]
4 changes: 2 additions & 2 deletions containers/rust-hello-world/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use the official Rust image as the build stage
FROM rust:1.79.0-alpine3.20 as builder
FROM rust:1.87.0-alpine3.21 as builder

# Set the working directory inside the container
WORKDIR /usr/src/app
Expand All @@ -11,7 +11,7 @@ COPY . .
RUN cargo build --release

# Use a smaller base image for the final container
FROM alpine:3.20
FROM alpine:3.21

# Copy the compiled binary from the build stage
COPY --from=builder /usr/src/app/target/release/hello-world /usr/local/bin/hello-world
Expand Down
5 changes: 2 additions & 3 deletions containers/rust-hello-world/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ This example demonstrates the deployment of a simple rust http service on Scalew
This can be useful if you come from Serverless Functions and you need to install specific dependencies on your system.

For this example, we will use the CLI to deploy the container, but you can use [other methods](https://www.scaleway.com/en/docs/serverless/containers/reference-content/deploy-container/).
You can also use the CLI directly from Scaleway console without having to use your credentials.

## Workflow

Expand Down Expand Up @@ -43,10 +42,10 @@ To complete the actions presented below, you must have:

At this point, you have correctly set up Docker to be able to push your image online.

1. In a terminal, access this directory (containing the Dockerfile), and run the following command to build the image:
1. In a terminal, access this directory (containing the Dockerfile), and run the following command to build and tag the image:

```bash
docker build -t crabnet:v1.0.0 .
docker build --platform linux/amd64 -t rg.fr-par.scw.cloud/hello-rust/crabnet:v1.0.0 .
```

1. Tag and push the image to the registry namespace:
Expand Down
8 changes: 5 additions & 3 deletions containers/rust-hello-world/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use std::{
io::{prelude::*, BufReader},
env,
io::{BufReader, prelude::*},
net::{TcpListener, TcpStream},
};

fn main() {
let listener = TcpListener::bind("127.0.0.1:8080").unwrap();
let port = env::var("PORT").unwrap_or_else(|_| "8080".to_string());
let listener = TcpListener::bind(format!("0.0.0.0:{}", port)).unwrap();

for stream in listener.incoming() {
let stream = stream.unwrap();
Expand All @@ -24,7 +26,7 @@ fn handle_connection(mut stream: TcpStream) {
.collect();

let status_line = "HTTP/1.1 200 OK";
let contents = "hello world";
let contents = "Hello from Scaleway!";
let length = contents.len();

let response = format!("{status_line}\r\nContent-Length: {length}\r\n\r\n{contents}");
Expand Down
Loading