roapi/Dockerfile
QP Hou 9ebc252011
Some checks failed
build / build (push) Has been cancelled
build / database_test (push) Has been cancelled
build / object_store_memory_test (push) Has been cancelled
build / object_store_direct_test (push) Has been cancelled
build / openssl_build (push) Has been cancelled
build / mac_cross_build (push) Has been cancelled
build / Docker Image Build (push) Has been cancelled
columnq-cli release / Validate git tag (push) Has been cancelled
roapi release / Validate git tag (push) Has been cancelled
columnq-cli release / macos (push) Has been cancelled
columnq-cli release / windows (map[features:database-sqlite python-architecture:x64 target:x86_64-pc-windows-msvc]) (push) Has been cancelled
columnq-cli release / linux (map[features:rustls,database-sqlite image_tag:aarch64-musl manylinux:2014 name_suffix: rustflags: target:aarch64-unknown-linux-musl upload:true]) (push) Has been cancelled
columnq-cli release / linux (map[features:rustls,database-sqlite image_tag:x86_64-musl manylinux:2010 name_suffix: rustflags:-C target-cpu=skylake target:x86_64-unknown-linux-musl upload:true]) (push) Has been cancelled
columnq-cli release / PyPI Release (push) Has been cancelled
roapi release / macos (push) Has been cancelled
roapi release / windows (map[features:database-sqlite python-architecture:x64 target:x86_64-pc-windows-msvc]) (push) Has been cancelled
roapi release / linux (map[features:rustls,database-sqlite image_tag:aarch64-musl manylinux:2014 name_suffix: rustflags: target:aarch64-unknown-linux-musl upload:true]) (push) Has been cancelled
roapi release / linux (map[features:rustls,database-sqlite image_tag:x86_64-musl manylinux:2010 name_suffix: rustflags:-C target-cpu=skylake target:x86_64-unknown-linux-musl upload:true]) (push) Has been cancelled
roapi release / PyPI Release (push) Has been cancelled
roapi release / Docker Image Release (push) Has been cancelled
remove lazy_static dep (#376)
2025-01-21 22:46:17 -08:00

52 lines
1.4 KiB
Docker

ARG RUST_VER=1.84.0-bookworm
ARG RUSTFLAGS='-C target-cpu=skylake'
ARG FEATURES="database"
# Step 0: Install cargo-chef
FROM rust:${RUST_VER} AS chef
# We only pay the installation cost once,
# it will be cached from the second build onwards
RUN cargo install cargo-chef
# install cmake for snmalloc
RUN apt-get update \
&& apt-get install --no-install-recommends -y cmake
# Step 1: Compute a recipe file
FROM chef AS planner
WORKDIR /roapi_src
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
# Step 2: Cache project dependencies
FROM chef AS cacher
ARG RUSTFLAGS
ARG FEATURES
WORKDIR /roapi_src
COPY --from=planner /roapi_src/recipe.json recipe.json
RUN RUSTFLAGS=${RUSTFLAGS} \
cargo chef cook --features ${FEATURES} --release --recipe-path recipe.json
# Step 3: Build the release binary
FROM chef AS builder
ARG RUSTFLAGS
ARG FEATURES
WORKDIR /roapi_src
COPY ./ /roapi_src
COPY --from=cacher /roapi_src/target target
COPY --from=cacher /usr/local/cargo /usr/local/cargo
RUN RUSTFLAGS=${RUSTFLAGS} \
cargo build --release --locked --bin roapi --features ${FEATURES}
# Step 4: Assemble the final image
FROM debian:bookworm-slim
LABEL org.opencontainers.image.source https://github.com/roapi/roapi
RUN apt-get update \
&& apt-get install -y libssl-dev ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY test_data /test_data
COPY --from=builder /roapi_src/target/release/roapi /usr/local/bin/roapi
EXPOSE 8080
ENTRYPOINT ["roapi"]