forked from grapl-security/grapl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
121 lines (85 loc) · 3.07 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
FROM rust:1-slim-buster AS base
ARG PROFILE=debug
SHELL ["/bin/bash", "-c"]
RUN apt-get update && apt-get install -y --no-install-recommends \
wait-for-it \
wget \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /tmp
RUN wget -q https://github.com/mozilla/sccache/releases/download/v0.2.15/sccache-v0.2.15-x86_64-unknown-linux-musl.tar.gz && \
tar xvzf sccache-v0.2.15-x86_64-unknown-linux-musl.tar.gz && \
chmod +x sccache-v0.2.15-x86_64-unknown-linux-musl/sccache && \
cp sccache-v0.2.15-x86_64-unknown-linux-musl/sccache /usr/local/bin/sccache
ENV RUSTC_WRAPPER=/usr/local/bin/sccache
WORKDIR /grapl
# copy sources
COPY . .
#
# build
#
# the `base` stage isn't used by the build system, but let's
# make `base` and `build` in case it becomes convenient.
FROM base AS build
RUN --mount=type=cache,mode=0777,target=/root/.cache/sccache \
--mount=type=secret,id=rust_env,dst=/grapl/env \
source /grapl/env; \
case "${PROFILE}" in \
debug) \
cargo build ;; \
release) \
cargo build --release ;; \
*) \
echo "ERROR: Unknown profile: ${PROFILE}"; \
exit 1 ;; \
esac
#
# build test stages
#
FROM build AS build-test-unit
RUN --mount=type=cache,mode=0777,target=/root/.cache/sccache \
--mount=type=secret,id=rust_env,dst=/grapl/env \
source /grapl/env; \
cargo test --no-run
FROM build AS build-test-integration
RUN --mount=type=cache,mode=0777,target=/root/.cache/sccache \
--mount=type=secret,id=rust_env,dst=/grapl/env \
source /grapl/env; \
cargo test --manifest-path node-identifier/Cargo.toml --features integration --no-run
#
# images for running services
#
FROM debian:buster-slim AS rust-dist
ARG PROFILE=debug
USER nobody
# analyzer-dispatcher
FROM rust-dist AS analyzer-dispatcher-deploy
COPY --from=build "/grapl/target/${PROFILE}/analyzer-dispatcher" /
CMD ["/analyzer-dispatcher"]
# generic-subgraph-generator
FROM rust-dist AS generic-subgraph-generator-deploy
COPY --from=build "/grapl/target/${PROFILE}/generic-subgraph-generator" /
CMD ["/generic-subgraph-generator"]
# graph-merger
FROM rust-dist AS graph-merger-deploy
COPY --from=build "/grapl/target/${PROFILE}/graph-merger" /
CMD ["/graph-merger"]
# metric-forwarder
FROM rust-dist AS metric-forwarder-deploy
COPY --from=build "/grapl/target/${PROFILE}/metric-forwarder" /
CMD ["/metric-forwarder"]
# node-identifier
FROM rust-dist AS node-identifier-deploy
COPY --from=build "/grapl/target/${PROFILE}/node-identifier" /
CMD ["/node-identifier"]
# node-identifier-retry-handler
FROM rust-dist AS node-identifier-retry-handler-deploy
COPY --from=build "/grapl/target/${PROFILE}/node-identifier-retry-handler" /
CMD ["/node-identifier-retry-handler"]
# sysmon-subgraph-generator
FROM rust-dist AS sysmon-subgraph-generator-deploy
COPY --from=build "/grapl/target/${PROFILE}/sysmon-subgraph-generator" /
CMD ["/sysmon-subgraph-generator"]
# osquery-subgraph-generator
FROM rust-dist AS osquery-subgraph-generator-deploy
COPY --from=build "/grapl/target/${PROFILE}/osquery-subgraph-generator" /
CMD ["/osquery-subgraph-generator"]