-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
44 lines (34 loc) · 1.73 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
# syntax=docker/dockerfile:1
# https://docs.docker.com/engine/reference/builder/
################################################################################
# Create a stage for building the application.
ARG RUST_VERSION=1.75.0
FROM rust:${RUST_VERSION}-slim-bullseye AS build
WORKDIR /app
RUN apt-get update && apt-get install --no-install-recommends --assume-yes build-essential llvm-dev libclang-dev clang libpcre3 libpcre3-dev zlib1g-dev pkg-config libssl-dev
# Build the application.
# Leverage a cache mount to /usr/local/cargo/registry/
# for downloaded dependencies and a cache mount to /app/target/ for
# compiled dependencies which will speed up subsequent builds.
# Leverage a bind mount to the src directory to avoid having to copy the
# source code into the container. Once built, copy the executable to an
# output directory before the cache mounted /app/target is unmounted.
RUN --mount=type=bind,source=src,target=src \
--mount=type=bind,source=build.rs,target=build.rs \
--mount=type=bind,source=DataAvailabilityChallenge.json,target=DataAvailabilityChallenge.json \
--mount=type=bind,source=Cargo.toml,target=Cargo.toml \
--mount=type=bind,source=Cargo.lock,target=Cargo.lock \
--mount=type=cache,target=/app/target/ \
--mount=type=cache,target=/usr/local/cargo/registry/ \
<<EOF
set -e
cargo build -p sentinel --locked --release
cp ./target/release/sentinel /bin/sentinel
EOF
################################################################################
# Create a stage for running the application.
FROM debian:bullseye-slim AS final
RUN apt-get update && apt-get install -y libssl-dev ca-certificates
# Copy the executable from the "build" stage.
COPY --from=build /bin/sentinel /bin/
CMD ["/bin/sentinel"]