-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add Dockerfile multi stages (#18)
- Loading branch information
Showing
2 changed files
with
23 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,24 @@ | ||
FROM rust:1-slim | ||
|
||
FROM rust:1 AS base | ||
WORKDIR /app | ||
|
||
FROM base AS dev | ||
RUN cargo install cargo-watch | ||
COPY . . | ||
CMD ["cargo", "watch", "-x", "run"] | ||
|
||
RUN cargo build | ||
FROM base AS planner | ||
RUN cargo install cargo-chef | ||
COPY . . | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
|
||
EXPOSE 8000 | ||
FROM base AS build | ||
COPY --from=planner /app/recipe.json recipe.json | ||
RUN cargo chef cook --release --recipe-path recipe.json | ||
COPY . . | ||
RUN cargo build --release --bin sudoku-rust | ||
|
||
CMD ["cargo", "run"] | ||
|
||
FROM debian:stable-slim AS prod | ||
WORKDIR /app | ||
COPY --from=build /app/target/release/sudoku-rust /usr/local/bin | ||
ENTRYPOINT ["/usr/local/bin/app"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters