37 lines
982 B
Docker
37 lines
982 B
Docker
# syntax=docker/dockerfile:1.3-labs
|
|
|
|
FROM rust:1.66.0 as build
|
|
|
|
COPY Cargo.toml Cargo.lock /app/
|
|
RUN cargo new /app/host
|
|
COPY host/Cargo.toml /app/host/
|
|
RUN cargo new --lib /app/kernel
|
|
COPY kernel/Cargo.toml /app/kernel/
|
|
RUN cargo new --lib /app/server
|
|
COPY server/Cargo.toml /app/server/
|
|
RUN cargo new --lib /app/tests
|
|
COPY tests/Cargo.toml /app/tests/
|
|
|
|
WORKDIR /app/host
|
|
RUN --mount=type=cache,target=/usr/local/cargo/registry cargo build --release
|
|
|
|
COPY ./host /app/host
|
|
COPY ./kernel /app/kernel
|
|
COPY ./server /app/server
|
|
|
|
RUN --mount=type=cache,target=/usr/local/cargo/registry <<EOF
|
|
set -e
|
|
# update timestamps to force a new build
|
|
touch /app/host/src/main.rs /app/server/src/lib.rs /app/kernel/src/lib.rs
|
|
cargo build --release
|
|
EOF
|
|
|
|
# our final base
|
|
FROM debian:buster-slim
|
|
|
|
# copy the build artifact from the build stage
|
|
COPY --from=build /app/target/release/host .
|
|
COPY --from=build /app/host/Rocket.toml .
|
|
|
|
# set the startup command to run your binary
|
|
CMD ["./host"] |