Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions Dockerfile
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"]
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ Go to the project directory
Build the docker image

```bash
docker build -t sudoku-rust .
# with live reload
docker build -t sudoku-rust --target=dev .

# release optimized
docker build -t sudoku-rust --target=prod .
```

Run the docker container
Expand Down