-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathDockerfile
93 lines (73 loc) · 2.84 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
###############################################################################
# Create the rust-builder
FROM rust:slim-buster AS rust-sysdeps
# needs perl to install and configure openssl
RUN apt-get update && \
apt-get install \
bc \
clang \
libssl-dev \
lld \
perl \
pkg-config \
make \
cmake \
protobuf-compiler \
libprotobuf-dev \
--no-install-recommends \
-y && \
rm -rf /var/lib/lapt/lists/*
# Setup default (stable) toolchain first in a separate layer (since it is
# less likely to change / more likely to be cached)
RUN rustup update && \
rustup component add clippy llvm-tools-preview rustfmt
RUN cargo install sccache
RUN echo "[build]\nrustc-wrapper = \"/usr/local/cargo/bin/sccache\""
FROM rust-sysdeps as rust-prepare
FROM rust-sysdeps as rust-builder
COPY --from=rust-prepare /usr/local/cargo/bin/sccache /usr/local/cargo/bin/sccache
###############################################################################
# Create the runtime environment
FROM debian:buster-slim as runtime
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates wget \
&& update-ca-certificates
# Install grpc-health-probe binary into container
RUN GRPC_HEALTH_PROBE_VERSION=v0.4.11 && \
wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \
chmod +x /bin/grpc_health_probe
###############################################################################
# Build the sparrow code
FROM rust-builder as sparrow-build
COPY ./*.toml /builds/kaskada/
COPY ./*.lock /builds/kaskada/
COPY ./NOTICE /builds/kaskada/
COPY ./crates/ /builds/kaskada/crates/
COPY ./proto/ /builds/kaskada/proto/
WORKDIR /builds/kaskada
# outputs to ./target/debug/sparrow-main
RUN cargo build --bin sparrow-main
###############################################################################
# Build the wren code
FROM golang:1.19.9 AS wren-build
RUN mkdir -p /builds/kaskada/wren
RUN mkdir -p /builds/kaskada/gen/proto/go
WORKDIR /builds/kaskada/wren
# Fetch dependencies.
COPY ./wren/go.mod /builds/kaskada/wren/
COPY ./wren/go.sum /builds/kaskada/wren/
COPY ./gen/proto/go/go.mod /builds/kaskada/gen/proto/go/
COPY ./gen/proto/go/go.sum /builds/kaskada/gen/proto/go/
RUN go mod download
#compile minimal executable
COPY NOTICE /builds/kaskada/wren/
COPY ./wren /builds/kaskada/wren
COPY ./gen/proto/go /builds/kaskada/gen/proto/go
RUN go build -ldflags="-w -s" -o /go/bin/wren main.go
###############################################################################
# create the final container
FROM runtime
COPY --from=sparrow-build /builds/kaskada/target/debug/sparrow-main /bin/sparrow-main
COPY --from=wren-build /go/bin/wren /bin/wren
COPY run.sh run.sh
CMD ["./run.sh"]