22# This Dockerfile builds the self-hosted version of the Convex backend
33# It creates a minimal runtime image that can run a local Convex instance
44
5+ ARG VERGEN_GIT_SHA
6+ ARG VERGEN_GIT_COMMIT_TIMESTAMP
57
68# cargo-chef is used to cache Rust dependencies and build artifacts
79# It creates a recipe of our dependencies first, then builds them in a separate stage
@@ -72,11 +74,12 @@ RUN --mount=type=cache,target=/convex/target/ --mount=type=cache,target=/usr/loc
7274COPY . .
7375
7476# Build the convex-local-backend binary
77+ # Must redeclare these as environment variables so that they are available
7578ARG VERGEN_GIT_SHA
7679ARG VERGEN_GIT_COMMIT_TIMESTAMP
80+ ENV VERGEN_GIT_SHA=${VERGEN_GIT_SHA}
81+ ENV VERGEN_GIT_COMMIT_TIMESTAMP=${VERGEN_GIT_COMMIT_TIMESTAMP}
7782RUN --mount=type=cache,target=/convex/npm-packages/common/temp/,sharing=locked --mount=type=cache,target=/convex/target/ --mount=type=cache,target=/usr/local/cargo/git/db --mount=type=cache,target=/usr/local/cargo/registry/ <<EOF
78- export VERGEN_GIT_SHA=${VERGEN_GIT_SHA}
79- export VERGEN_GIT_COMMIT_TIMESTAMP=${VERGEN_GIT_COMMIT_TIMESTAMP}
8083cargo build --release -p local_backend --bin convex-local-backend
8184cp target/release/convex-local-backend .
8285cargo build --release -p keybroker --bin generate_key
@@ -88,6 +91,7 @@ RUN if [[ -z "$debug" ]]; then strip ./convex-local-backend; strip ./generate_ke
8891# Final stage: Creates minimal runtime image with only necessary components
8992# Uses Ubuntu Noble (24.04) as the base image
9093FROM ubuntu:noble
94+ ARG VERGEN_GIT_SHA
9195LABEL org.opencontainers.repository=https://github.com/get-convex/convex-backend
9296LABEL org.opencontainers.image.revision=${VERGEN_GIT_SHA}
9397
0 commit comments