|
| 1 | +#syntax=docker/dockerfile:1.2 |
| 2 | +ARG RUST_VERSION=1.75 |
| 3 | +FROM rust:${RUST_VERSION}-slim-bookworm as build |
| 4 | + |
| 5 | +# cache mounts below may already exist and owned by root |
| 6 | +USER root |
| 7 | + |
| 8 | +RUN apt update \ |
| 9 | + && apt install --yes binutils build-essential pkg-config libssl-dev clang lld git protobuf-compiler \ |
| 10 | + && rm -rf /var/lib/{apt,dpkg,cache,log} |
| 11 | + |
| 12 | +# Build influxdb3 |
| 13 | +COPY . /influxdb3 |
| 14 | +WORKDIR /influxdb3 |
| 15 | + |
| 16 | +ARG CARGO_INCREMENTAL=yes |
| 17 | +ARG CARGO_NET_GIT_FETCH_WITH_CLI=false |
| 18 | +ARG PROFILE=release |
| 19 | +ARG FEATURES=aws,gcp,azure,jemalloc_replacing_malloc |
| 20 | +ARG PACKAGE=influxdb3 |
| 21 | +ENV CARGO_INCREMENTAL=$CARGO_INCREMENTAL \ |
| 22 | + CARGO_NET_GIT_FETCH_WITH_CLI=$CARGO_NET_GIT_FETCH_WITH_CLI \ |
| 23 | + PROFILE=$PROFILE \ |
| 24 | + FEATURES=$FEATURES \ |
| 25 | + PACKAGE=$PACKAGE |
| 26 | + |
| 27 | +RUN \ |
| 28 | + --mount=type=cache,id=influxdb3_rustup,sharing=locked,target=/usr/local/rustup \ |
| 29 | + --mount=type=cache,id=influxdb3_registry,sharing=locked,target=/usr/local/cargo/registry \ |
| 30 | + --mount=type=cache,id=influxdb3_git,sharing=locked,target=/usr/local/cargo/git \ |
| 31 | + --mount=type=cache,id=influxdb3_target,sharing=locked,target=/influxdb_iox/target \ |
| 32 | + du -cshx /usr/local/rustup /usr/local/cargo/registry /usr/local/cargo/git /influxdb_iox/target && \ |
| 33 | + cargo build --target-dir /influxdb3/target --package="$PACKAGE" --profile="$PROFILE" --no-default-features --features="$FEATURES" && \ |
| 34 | + objcopy --compress-debug-sections "target/$PROFILE/$PACKAGE" && \ |
| 35 | + cp "/influxdb3/target/$PROFILE/$PACKAGE" /root/$PACKAGE && \ |
| 36 | + du -cshx /usr/local/rustup /usr/local/cargo/registry /usr/local/cargo/git /influxdb_iox/target |
| 37 | + |
| 38 | + |
| 39 | +FROM debian:bookworm-slim |
| 40 | + |
| 41 | +RUN apt update \ |
| 42 | + && apt install --yes ca-certificates gettext-base libssl3 --no-install-recommends \ |
| 43 | + && rm -rf /var/lib/{apt,dpkg,cache,log} \ |
| 44 | + && groupadd --gid 1500 influxdb3 \ |
| 45 | + && useradd --uid 1500 --gid influxdb3 --shell /bin/bash --create-home influxdb3 |
| 46 | + |
| 47 | +USER influxdb3 |
| 48 | + |
| 49 | +RUN mkdir ~/.influxdb3 |
| 50 | + |
| 51 | +ARG PACKAGE=influxdb3 |
| 52 | +ENV PACKAGE=$PACKAGE |
| 53 | + |
| 54 | +COPY --from=build "/root/$PACKAGE" "/usr/bin/$PACKAGE" |
| 55 | +COPY docker/entrypoint.sh /usr/bin/entrypoint.sh |
| 56 | + |
| 57 | +EXPOSE 8080 8082 |
| 58 | + |
| 59 | +ENTRYPOINT ["/usr/bin/entrypoint.sh"] |
| 60 | + |
| 61 | +CMD ["serve"] |
0 commit comments