-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
61 lines (49 loc) · 1.67 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
# build stage for cargo-chef
FROM rust:1.78.0 AS chef
WORKDIR /app
RUN cargo install cargo-chef
# planning stage
FROM chef AS planner
COPY Cargo.toml Cargo.lock crates ./app/
RUN cargo chef prepare --recipe-path recipe.json
# caching stage
FROM chef AS cacher
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --recipe-path recipe.json
# final build stage
FROM chef AS builder
COPY . .
RUN cargo build --release --bin ndc-calcite --bin ndc-calcite-cli
# java-build stage
FROM debian:trixie-slim AS java-build
COPY scripts/java_env_jdk.sh ./scripts/
RUN apt-get update && apt-get install -y openjdk-21-jdk maven ca-certificates
RUN . /scripts/java_env_jdk.sh
RUN java -version && mvn --version
COPY calcite-rs-jni/ /calcite-rs-jni/
RUN mkdir -p /root/.m2 /root/.gradle
VOLUME /root/.m2 /root/.gradle
WORKDIR /calcite-rs-jni
RUN sh build.sh
# Put all the jars into target/dependency folder
RUN mvn dependency:copy-dependencies
# runtime stage
FROM debian:trixie-slim AS runtime
COPY scripts/java_env_jre.sh ./scripts/
RUN apt-get update && \
apt-get install -y openjdk-21-jre-headless && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
RUN . /scripts/java_env_jre.sh && \
mkdir -p /calcite-rs-jni/jni/target && \
mkdir -p /etc/ndc-calcite && \
mkdir -p /app/connector && \
chmod -R 666 /app/connector
COPY --from=builder /app/target/release/ndc-calcite /usr/local/bin
COPY --from=builder /app/target/release/ndc-calcite-cli /usr/local/bin
COPY --from=java-build /calcite-rs-jni/jni/target/ /calcite-rs-jni/jni/target/
ENV HASURA_CONFIGURATION_DIRECTORY=/etc/connector
ENV RUST_BACKTRACE=full
WORKDIR /app
ENTRYPOINT ["ndc-calcite"]
CMD ["serve"]