mirror of
https://github.com/roapi/roapi.git
synced 2026-06-05 21:04:02 +08:00
Some checks failed
build / build (push) Has been cancelled
build / build_ui (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
## About The existing healtcheck endpoint http://localhost:8080/health can now be used without much ado within Docker Compose service definitions, and it works well. ```yaml healthcheck: test: ["CMD", "curl", "--fail", "http://localhost:8080/health"] start_period: 3s interval: 1.5s retries: 30 timeout: 30s ``` ## References - Resolves: https://github.com/roapi/roapi/issues/418 - See also: https://github.com/crate/cratedb-examples/pull/1320#pullrequestreview-3601457082
57 lines
1.7 KiB
Docker
57 lines
1.7 KiB
Docker
ARG RUST_VER=1.86.0-bookworm
|
|
ARG FEATURES="database,ui"
|
|
|
|
# Step 0: Install cargo-chef
|
|
FROM rust:${RUST_VER} AS chef
|
|
|
|
RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
|
|
RUN cargo binstall trunk
|
|
|
|
# Add WebAssembly target for UI build
|
|
RUN rustup target add wasm32-unknown-unknown
|
|
|
|
# We only pay the installation cost once,
|
|
# it will be cached from the second build onwards
|
|
RUN cargo binstall 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 FEATURES
|
|
WORKDIR /roapi_src
|
|
COPY --from=planner /roapi_src/recipe.json recipe.json
|
|
RUN cargo chef cook --features ${FEATURES} --release --recipe-path recipe.json
|
|
|
|
# Step 3: Build the UI and release binary
|
|
FROM chef AS builder
|
|
ARG FEATURES
|
|
WORKDIR /roapi_src
|
|
COPY ./ /roapi_src
|
|
COPY --from=cacher /roapi_src/target target
|
|
COPY --from=cacher /usr/local/cargo /usr/local/cargo
|
|
# First build the UI
|
|
RUN cd roapi-ui && trunk build --release
|
|
# Then build the ROAPI binary with the UI embedded
|
|
RUN 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 curl \
|
|
&& 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"]
|