Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
funlennysub committed Jul 21, 2024
0 parents commit 1d04160
Show file tree
Hide file tree
Showing 6 changed files with 213 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Dockerfile
target/
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/target

.idea/
160 changes: 160 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "progress-bar-test"
version = "0.1.0"
edition = "2021"

[dependencies]
indicatif = "0.17.8"
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM lukemathwalker/cargo-chef:latest-rust-1.79.0 AS chef
WORKDIR /app

FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json

FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
# Build dependencies - this is the caching Docker layer!
RUN cargo chef cook --release --recipe-path recipe.json
# Build application
COPY . .
RUN cargo build --release --bin progress-bar-test

# We do not need the Rust toolchain to run the binary!
FROM debian:bookworm-slim AS runtime
WORKDIR /app
COPY --from=builder /app/target/release/progress-bar-test /progress-bar-test
RUN chmod 0744 /progress-bar-test
CMD ["/progress-bar-test"]
20 changes: 20 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use std::thread::sleep;
use std::time::Duration;
use indicatif::{ProgressBar, ProgressStyle};

fn main() {
println!("Progress bar");
let len = 500;
let style = ProgressStyle::with_template("[{elapsed_precise}] {bar:40.cyan/blue} {human_pos}/{human_len} {msg}")
.unwrap()
.progress_chars("##-");
let bar = ProgressBar::new(len).with_style(style);

for _ in 0..=len {
sleep(Duration::from_millis(10));
bar.inc(1);
}
bar.finish_with_message("Done");

println!("Hello, world!");
}

0 comments on commit 1d04160

Please sign in to comment.