-
Notifications
You must be signed in to change notification settings - Fork 904
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build cozo-bin docker image directly from the cozo repo
- Loading branch information
Diwank Tomer
committed
Aug 26, 2024
1 parent
af0d4d4
commit d2eeb3f
Showing
2 changed files
with
39 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,62 @@ | ||
FROM ubuntu:jammy | ||
# We need to build the cozo binary first from the repo | ||
# https://github.com/cozodb/cozo | ||
# Then copy the binary to the ./bin directory | ||
# Then copy the run.sh script to the ./run.sh file | ||
|
||
# First stage: Build the Rust project | ||
FROM rust:1.80.1-bookworm as builder | ||
|
||
# Install liburing-dev | ||
RUN apt-get update && apt-get install -y liburing-dev | ||
|
||
# Clone the CozoDB repository with submodules (checkout the specified commit) | ||
ARG COZO_COMMIT=57b7b440fd93440d985f2259eeaaf2ba5cc7569e | ||
RUN \ | ||
git clone --depth 1 --recurse-submodules --shallow-submodules https://github.com/cozodb/cozo.git /usr/src/cozo && \ | ||
cd /usr/src/cozo && \ | ||
git checkout $COZO_COMMIT | ||
|
||
# Set the working directory | ||
WORKDIR /usr/src/cozo | ||
# Build CozoDB | ||
RUN cargo build --release -p cozo-bin --features "requests graph-algo storage-rocksdb storage-sqlite jemalloc io-uring" | ||
|
||
# Copy the built binary to /usr/local/bin | ||
RUN cp target/release/cozo-bin /usr/local/bin/cozo | ||
|
||
# ------------------------------------------------------------------------------------------------- | ||
|
||
# Second stage: Create the final image | ||
FROM debian:bookworm-slim | ||
|
||
# Install dependencies | ||
RUN \ | ||
apt-get update -yqq && \ | ||
apt-get install -y ca-certificates tini nfs-common nfs-kernel-server netcat procps netbase && \ | ||
apt-get install -y ca-certificates tini nfs-common nfs-kernel-server procps netbase && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
# Set fallback mount directory | ||
ENV MNT_DIR /data | ||
|
||
# Copy local code to the container image. | ||
ENV APP_HOME /app | ||
WORKDIR $APP_HOME | ||
COPY ./bin ./bin | ||
|
||
# Copy the cozo binary | ||
COPY --from=builder /usr/local/bin/cozo $APP_HOME/bin/cozo-bin | ||
|
||
# Copy local code to the container image. | ||
COPY ./run.sh ./run.sh | ||
|
||
# Ensure the script is executable | ||
RUN \ | ||
mkdir -p $MNT_DIR && \ | ||
chmod +x /app/bin/cozo-bin && \ | ||
chmod +x /app/run.sh | ||
chmod +x $APP_HOME/bin/cozo-bin && \ | ||
chmod +x $APP_HOME/run.sh | ||
|
||
# Use tini to manage zombie processes and signal forwarding | ||
# https://github.com/krallin/tini | ||
ENTRYPOINT ["/usr/bin/tini", "--"] | ||
|
||
# Pass the startup script as arguments to tini | ||
CMD ["/app/run.sh"] | ||
CMD ["/app/run.sh"] |
Binary file not shown.