forked from huff-language/huff-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
47 lines (31 loc) · 1.14 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# ------------------ Chef stage -------------------
# Use cargo chef to cache dependencies
FROM rustlang/rust:nightly AS chef
# Install cargo chef
RUN cargo install cargo-chef
# Work in app
WORKDIR /app
# ------------------ Planner stage -------------------
FROM chef as planner
# Copy files into container
COPY . .
# Create a lockfile for cargo chef
RUN cargo +nightly chef prepare --recipe-path recipe.json
# ------------------ Builder stage -------------------
FROM chef AS builder
# Copy over our lock file
COPY --from=planner /app/recipe.json recipe.json
# Build dependencies - not the app
RUN cargo chef cook --release --recipe-path recipe.json
### Above this all dependencies should be cached as long as our lock file stays the same
COPY . .
# Build binary
RUN cargo build --release
# ------------------ Runtime stage -------------------
# Using super lightweight debian image to reduce overhead
FROM debian:bullseye-slim AS runtime
WORKDIR /app
# Copy prebuild bin from the Builder stage
COPY --from=builder /app/target/release/huffc /usr/local/bin/huffc
# Run bin which has been copied from the builder stage :)
ENTRYPOINT [ "/bin/sh", "-c" ]