-
Notifications
You must be signed in to change notification settings - Fork 536
/
Dockerfile
150 lines (105 loc) · 5.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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
FROM ubuntu:22.04 AS base
ENV LANG en_US.utf8
RUN apt-get update \
&& apt-get -y install ca-certificates build-essential libsasl2-dev openjdk-11-jdk
# Install Python 3.12
RUN apt-get -y install software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa -y && \
apt-get update -yy && \
DEBIAN_FRONTEND=noninteractive apt-get install python3.12 python3.12-dev -yy
ENV PYO3_PYTHON=python3.12
FROM base AS dashboard-builder
RUN apt-get update && apt-get install -y curl gnupg protobuf-compiler && mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
&& apt-get update && apt-get install -y nodejs
COPY ./dashboard/ /risingwave/dashboard
COPY ./proto /risingwave/proto
RUN cd /risingwave/dashboard && npm i && npm run build-static && rm -rf node_modules
FROM base AS rust-base
RUN apt-get update && apt-get -y install make cmake protobuf-compiler curl bash lld unzip
SHELL ["/bin/bash", "-c"]
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --no-modify-path --default-toolchain none -y
ENV PATH /root/.cargo/bin/:$PATH
ENV CARGO_INCREMENTAL=0
COPY rust-toolchain rust-toolchain
# We need to add the `rustfmt` dependency, otherwise `risingwave_pb` will not compile
RUN rustup self update \
&& rustup set profile minimal \
&& rustup show \
&& rustup component add rustfmt \
&& rustup target add wasm32-wasi
RUN cargo install flamegraph
# TODO: cargo-chef doesn't work well now, because we update Cargo.lock very often.
# We may consider sccache instead.
# RUN cargo install --git https://github.com/xxchan/cargo-chef cargo-chef --locked --rev 11f9fed
# FROM rust-base AS rust-planner
# RUN mkdir -p /risingwave
# WORKDIR /risingwave
# COPY ./ /risingwave
# RUN cargo chef prepare --recipe-path recipe.json
# FROM rust-base AS rust-builder
# RUN mkdir -p /risingwave
# WORKDIR /risingwave
# COPY --from=rust-planner /risingwave/recipe.json recipe.json
# # Build dependencies - this can be cached if the dependencies don't change
# RUN cargo chef cook --release --recipe-path recipe.json
FROM rust-base AS rust-builder
# Build application
ARG GIT_SHA
ENV GIT_SHA=$GIT_SHA
COPY ./ /risingwave
WORKDIR /risingwave
RUN cargo fetch && \
cargo build -p risingwave_cmd_all --release --features "rw-static-link" --features embedded-python-udf && \
mkdir -p /risingwave/bin && \
mv /risingwave/target/release/risingwave /risingwave/bin/ && \
mv /risingwave/target/release/risingwave.dwp /risingwave/bin/ && \
cp ./target/release/build/tikv-jemalloc-sys-*/out/build/bin/jeprof /risingwave/bin/ && \
chmod +x /risingwave/bin/jeprof && \
mkdir -p /risingwave/lib && cargo clean
FROM base AS java-planner
RUN mkdir -p /risingwave
WORKDIR /risingwave
COPY java /risingwave/java/
# Move java/**/pom.xml to poms/**/pom.xml
RUN find . -name pom.xml -exec bash -c 'mkdir -p poms/$(dirname {}); mv {} poms/{}' \;
# We use rust-maven-plugin to build java-binding. So it's FROM rust-base
FROM rust-base AS java-builder
RUN apt-get update && apt-get -y install maven
RUN mkdir -p /risingwave
WORKDIR /risingwave/java
# 1. copy only poms
COPY --from=java-planner /risingwave/poms /risingwave/java/
# 2. start downloading dependencies
RUN mvn dependency:go-offline --fail-never
# 3. add all source code and start compiling
# TODO: only add java related code so that changing rust code won't recompile java code
# Currently java-binding depends on the workspace Cargo.toml, which depends on the whole rust codebase
# Besides, rust-maven-plugin sets --target-dir, so the dependencies are built twice. How to dedup?
COPY ./ /risingwave
RUN mvn -B package -Dmaven.test.skip=true -Dno-build-rust && \
mkdir -p /risingwave/bin/connector-node && \
tar -zxvf /risingwave/java/connector-node/assembly/target/risingwave-connector-1.0.0.tar.gz -C /risingwave/bin/connector-node
FROM base AS risingwave
LABEL org.opencontainers.image.source https://github.com/risingwavelabs/risingwave
RUN apt-get update && apt-get -y install linux-tools-generic \
&& ln -s "$(find /usr/lib/linux-tools/*/perf | head -1)" /usr/local/bin/perf
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install gdb libpam-krb5 krb5-user telnet kafkacat \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/
RUN mkdir -p /risingwave/bin/connector-node && mkdir -p /risingwave/lib
COPY --from=rust-builder /risingwave/bin/risingwave /risingwave/bin/risingwave
COPY --from=rust-builder /risingwave/bin/risingwave.dwp /risingwave/bin/risingwave.dwp
COPY --from=java-builder /risingwave/bin/connector-node /risingwave/bin/connector-node
COPY --from=dashboard-builder /risingwave/dashboard/out /risingwave/ui
COPY --from=rust-builder /risingwave/bin/jeprof /usr/local/bin/jeprof
COPY --from=rust-base /root/.cargo/bin/flamegraph /usr/local/bin/flamegraph
# Set default playground mode to docker-playground profile
ENV PLAYGROUND_PROFILE docker-playground
# Set default dashboard UI to local path instead of github proxy
ENV RW_DASHBOARD_UI_PATH /risingwave/ui
# Set default connector libs path
ENV CONNECTOR_LIBS_PATH /risingwave/bin/connector-node/libs
ENV IN_CONTAINER=1
ENTRYPOINT [ "/risingwave/bin/risingwave" ]
CMD [ "playground" ]