Skip to content

Commit 5258ddc

Browse files
committed
Dockerfile from scratch
1 parent f997b91 commit 5258ddc

File tree

4 files changed

+55
-14
lines changed

4 files changed

+55
-14
lines changed

Cargo.lock

Lines changed: 41 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ axum = "0.7.5"
88
axum-extra = { version = "0.9.3", features = ["form"] }
99
base64 = "0.22.1"
1010
chrono = "0.4.38"
11+
ctrlc = { version = "3.4.5", features = ["termination"] }
1112
html-escape = "0.2.13"
1213
regex = "1.10.6"
1314
rustc_version_runtime = "0.3.0"

Dockerfile

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
1-
FROM rust:1-bookworm as builder
1+
FROM rust:latest AS builder
22

3-
RUN apt-get update && apt-get install -y \
4-
ca-certificates \
5-
dumb-init
3+
RUN rustup target add x86_64-unknown-linux-musl
4+
RUN apt update && apt install -y musl-tools musl-dev
65

76
WORKDIR /app
87
COPY . .
9-
RUN cargo build --bins --release
8+
RUN cargo build --target x86_64-unknown-linux-musl --release
109

11-
FROM debian:bookworm-slim
12-
LABEL org.opencontainers.image.source https://github.com/regexplanet/regexplanet-rust
10+
RUN find .
11+
12+
FROM scratch
1313

1414
ARG COMMIT="(not set)"
1515
ARG LASTMOD="(not set)"
1616
ENV COMMIT=$COMMIT
1717
ENV LASTMOD=$LASTMOD
1818

1919
WORKDIR /app
20-
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
21-
COPY --from=builder /usr/bin/dumb-init /usr/bin/dumb-init
22-
COPY --from=builder /app/target/release/regexplanet-rust /app/regexplanet-rust
20+
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/regexplanet-rust /app/regexplanet-rust
2321
COPY ./static /app/static
24-
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
2522
CMD ["/app/regexplanet-rust"]

src/main.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ use html_escape::encode_text;
1111

1212
#[tokio::main]
1313
async fn main() {
14+
15+
ctrlc::set_handler(move || {
16+
std::process::exit(0);
17+
}).expect("Error setting Ctrl-C handler");
18+
1419
// build our application with a single route
1520
let app = Router::new()
1621
//.route_service("/", get(|| async { axum::Redirect::temporary("https://www.regexplanet.com/advanced/rust/index.html") }))

0 commit comments

Comments
 (0)