forked from stouset/secrets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
48 lines (39 loc) · 1.33 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
48
FROM rust:latest
# we depend upon:
# * >= 1.32 for uniform module paths
# * >= 1.36 for std::mem::MaybeUninit
# * >= 1.38 for std::ptr::cast
# * >= 1.40 for cfg(doctest) (in a dependency)
# * >= 1.51 for const generics
ARG TOOLCHAIN
ENV TOOLCHAIN=${TOOLCHAIN:-1.51}
RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && \
apt-get dist-upgrade -y && \
apt-get install -y \
libsodium-dev
RUN --mount=type=cache,target=/tmp/cache/cargo \
--mount=type=cache,target=/tmp/cache/target,sharing=private \
rustup toolchain install $TOOLCHAIN && \
rustup default $TOOLCHAIN && \
rustup component add clippy
RUN mkdir /srv/secrets
WORKDIR /srv/secrets
ENV CARGO_HOME=/tmp/cache/cargo
ENV CARGO_TARGET_DIR=/tmp/cache/target
# pre-install dependencies so they can be cached
RUN mkdir ./src && touch ./src/lib.rs
COPY Cargo.toml .
RUN --mount=type=cache,target=/tmp/cache/cargo \
--mount=type=cache,target=/tmp/cache/target,sharing=private \
cargo build
ARG PROFILE=debug
ARG RUSTFLAGS="-A warnings"
ARG RUSTDOCFLAGS=""
# replace the dummy application with ours
COPY . .
RUN --mount=type=cache,target=/tmp/cache/cargo \
--mount=type=cache,target=/tmp/cache/target,sharing=private \
cargo clippy && \
cargo test && \
cargo doc