Skip to content

Commit

Permalink
Modify Dockerfile for Rust application
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallku committed Feb 8, 2024
1 parent 0d1d3e0 commit 0809b36
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.github
33 changes: 23 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
FROM python:3.10-slim as base
FROM rust:1.73-alpine AS chef

WORKDIR /app
WORKDIR /usr/src/marshallku-blog-cdn

RUN apt-get update && apt-get install -y magic libmagic-dev
RUN set -eux; \
apk add --no-cache musl-dev pkgconfig libressl-dev; \
cargo install cargo-chef; \
rm -rf $CARGO_HOME/registry

COPY requirements.txt /app/requirements.txt
FROM chef as planner

RUN pip install --no-cache-dir -r requirements.txt
RUN pip install gunicorn
COPY . .
RUN cargo chef prepare --recipe-path recipe.json

FROM base as runner
FROM chef AS builder

COPY ./app.py /app/app.py
COPY --from=planner /usr/src/marshallku-blog-cdn/recipe.json .
RUN cargo chef cook --release --recipe-path recipe.json

EXPOSE 41890
COPY . .
RUN cargo build --release

CMD ["gunicorn", "-b", "0.0.0.0:41890", "app:app"]
FROM alpine:3.14

WORKDIR /usr/local/bin

COPY --from=builder /usr/src/marshallku-blog-cdn/target/release/marshallku-blog-cdn .

EXPOSE 41880

CMD ["./marshallku-blog-cdn"]

0 comments on commit 0809b36

Please sign in to comment.