rewrite URL shortener in Rust

This commit is contained in:
2026-07-10 04:46:34 +00:00
parent a250ce4c1d
commit a6e8be7553
16 changed files with 2906 additions and 1102 deletions
+29
View File
@@ -0,0 +1,29 @@
FROM rust:1.96.1-alpine3.24 AS source
RUN apk add --no-cache musl-dev
WORKDIR /src
COPY Cargo.toml Cargo.lock ./
COPY config.example.toml ./
COPY src ./src
COPY static ./static
FROM source AS tester
RUN cargo test --locked --all-targets
FROM source AS builder
RUN cargo build --locked --release
FROM scratch
LABEL org.opencontainers.image.title="ushort" \
org.opencontainers.image.description="Self-contained URL shortener" \
org.opencontainers.image.source="https://git.xcel.me/cabbage/ushort"
WORKDIR /app
COPY --from=builder --chmod=0555 /src/target/release/ushort /ushort
USER 65532:65532
EXPOSE 8080
ENTRYPOINT ["/ushort"]
CMD ["/app/config.toml"]