graphql-engine/v3/Dockerfile
Manas Agarwal e27e5b7ffe v3: open-source hasura v3 engine
Hasura V3 Engine v3.alpha.12-19-2023
V3-GitOrigin-RevId: 6605575a52b347b5e9a14ecd1cc736f113c663b3

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/10567
Co-authored-by: Vishnu Bharathi <4211715+scriptnull@users.noreply.github.com>
GitOrigin-RevId: 38c98a4b1971efe3ac724c2371c43ceb7d31f140
2023-12-19 09:05:39 +00:00

69 lines
1.7 KiB
Docker

# See https://github.com/LukeMathWalker/cargo-chef
FROM rust:1.72.0 as chef
WORKDIR app
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive \
apt-get install --no-install-recommends --assume-yes \
lld protobuf-compiler libssl-dev ssh git pkg-config curl jq
ENV CARGO_HOME=/app/.cargo
RUN cargo install cargo-chef just grcov critcmp cargo-nextest
RUN rustup component add clippy
RUN rustup component add rustfmt
# needed for coverage reporting
RUN rustup component add llvm-tools-preview
RUN mkdir -p -m 0700 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
###
# Plan recipe
FROM chef AS planner
ENV CARGO_HOME=/app/.cargo
ENV RUSTFLAGS="-C link-arg=-fuse-ld=lld"
COPY . .
RUN --mount=type=ssh cargo chef prepare --recipe-path recipe.json
###
# Build recipe
FROM chef AS builder
# Use lld
ENV CARGO_HOME=/app/.cargo
ENV PATH="$PATH:$CARGO_HOME/bin"
ENV RUSTFLAGS="-C link-arg=-fuse-ld=lld"
COPY --from=planner /app/recipe.json recipe.json
COPY --from=planner /app/.cargo/config.toml /app/.cargo/config.toml
# Build dependencies - this is the caching Docker layer!
RUN --mount=type=ssh cargo chef cook --release --all-targets --recipe-path recipe.json
RUN --mount=type=ssh cargo chef cook --all-targets --recipe-path recipe.json
# Copies the source after building dependencies to allow caching
COPY . .
###
# Builds the application
FROM builder AS built
# Build the app
RUN cargo build --release
###
# Ship the app in an image with `curl` and very little else
FROM ubuntu:jammy
# Install `curl` for health checks
RUN set -ex; \
apt-get update -q; \
apt-get install -q -y curl
# Install the engine
COPY --from=built /app/target/release/engine /usr/local/bin
ENTRYPOINT ["engine"]