Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Dockerfile #48

Merged
merged 1 commit into from
Jan 11, 2021
Merged
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
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM rust:1.48 as planner
WORKDIR app

RUN cargo install cargo-chef
COPY . .

# Analyze dependencies
RUN cargo chef prepare --recipe-path recipe.json

FROM rust:1.48 as cacher
WORKDIR app
RUN cargo install cargo-chef
COPY --from=planner /app/recipe.json recipe.json

# Cache dependencies
RUN cargo chef cook --release --recipe-path recipe.json

FROM rust:1.48 as builder
WORKDIR app
COPY . .

# Copy over the cached dependencies
COPY --from=cacher /app/target target
COPY --from=cacher $CARGO_HOME $CARGO_HOME
RUN cargo build --release

FROM ubuntu:20.10 as runtime
WORKDIR app

RUN apt-get update \
&& DEBIAN_FRONTEND="noninteractive" apt-get install -y ca-certificates tzdata \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder /app/target/release/scaphandre /usr/local/bin
ENTRYPOINT ["/usr/local/bin/scaphandre"]