Skip to content

Commit

Permalink
web server dockerized
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhar-kotekar committed Jun 22, 2024
1 parent c75bbbd commit 1b6b128
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ build_web: prepare
# --progress plain
docker build -t rust_web:latest -f rusk_web/Dockerfile .
@echo "web server built successfully!"
@echo "run 'docker run -p 8080:5056 rust_web:latest' to start the server"
@echo "run 'docker run -it -p 8080:5056 rust_web:latest' to start the server"

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Accepts requests from UI and takes actions like adding a processor, connecting 2
Execute `make build_web` command build Docker image

## Useful commands:
### Add a new library package
- Execute `cargo new --lib <PACKAGE_NAME> --vcs none`
- To add a new library package, Execute `cargo new --lib <PACKAGE_NAME> --vcs none`
- To run an individual package within a workspace, execute `cargo run -p <MODULE NAME>`. Example : `cargo run -p rusk_web`

## Plan
- [x] Create simplest possible processor
Expand Down
2 changes: 1 addition & 1 deletion rusk_web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN echo $(ls -ltrh /rusk_web_app)
RUN cargo clean && \
cargo test --package commons && \
cargo test --package rusk_web && \
cargo build --release
cargo build --package rusk_web --release

RUN echo $(ls -ltrh /rusk_web_app/target/release/)

Expand Down
5 changes: 3 additions & 2 deletions rusk_web/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ const SERVER_PORT: &str = "5056";
#[tokio::main]
async fn main() {
commons::enable_tracing();
let server_address = format!("localhsot:{}", SERVER_PORT);
tracing::info!("Starting rusk web server on: {}", server_address);
let server_address = format!("0.0.0.0:{}", SERVER_PORT);
tracing::info!("Starting rusk web server on {}", server_address);
let server = Router::new().route("/", get(root));
let listener = tokio::net::TcpListener::bind(server_address).await.unwrap();
axum::serve(listener, server).await.unwrap();
}

async fn root() -> &'static str {
tracing::info!("Received request");
"Hello, World!"
}

Expand Down

0 comments on commit 1b6b128

Please sign in to comment.