ci(docker): add Dockerfile
This commit is contained in:
parent
17ae6a036e
commit
71c5915628
8
.dockerignore
Normal file
8
.dockerignore
Normal file
@ -0,0 +1,8 @@
|
||||
target/
|
||||
.git/
|
||||
.gitignore
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
README.md
|
||||
.env
|
||||
*.md
|
||||
43
Dockerfile
Normal file
43
Dockerfile
Normal file
@ -0,0 +1,43 @@
|
||||
FROM rust:1.94 AS chef
|
||||
|
||||
RUN cargo install --locked cargo-chef
|
||||
WORKDIR /app
|
||||
|
||||
COPY Cargo.toml Cargo.lock .
|
||||
RUN mkdir src && touch src/main.rs
|
||||
|
||||
RUN cargo chef prepare --recipe-path recipe.json
|
||||
|
||||
|
||||
|
||||
FROM chef AS builder
|
||||
|
||||
COPY --from=chef /app/recipe.json recipe.json
|
||||
|
||||
RUN cargo chef cook --release --recipe-path recipe.json
|
||||
|
||||
|
||||
COPY rust-toolchain.toml rust-toolchain.toml
|
||||
|
||||
RUN cargo fetch
|
||||
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN cargo build --release
|
||||
|
||||
|
||||
|
||||
FROM debian:bookworm-slim AS runtime
|
||||
|
||||
RUN useradd -m -s /bin/bash appuser
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /app/target/release/mdpreview /usr/local/bin/mdpreview
|
||||
|
||||
USER appuser
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["mdpreview"]
|
||||
Loading…
x
Reference in New Issue
Block a user