graphql-engine/v3/Dockerfile
Daniel Harvey 64657639d4 Use Rust 1.79.0 (#751)
<!-- Thank you for submitting this PR! :) -->

## Description

Upgrade Rust, as a treat. Functional no-op.

---------

Co-authored-by: Samir Talwar <samir@functional.computer>
V3_GIT_ORIGIN_REV_ID: 1e0014049e89b8658326c8d8f652df800c415526
2024-06-27 22:22:01 +00:00

74 lines
1.7 KiB
Docker

# This should match the Rust version in rust-toolchain.yaml and the other Dockerfiles.
FROM rust:1.79.0 as chef
WORKDIR app
ENV DEBIAN_FRONTEND=noninteractive
RUN set -ex;\
apt-get update; \
apt-get install --no-install-recommends --assume-yes \
curl git jq pkg-config ssh \
libssl-dev lld protobuf-compiler
# Set up a directory to store Cargo files.
ENV CARGO_HOME=/app/.cargo
ENV PATH="$PATH:$CARGO_HOME/bin"
# Switch to `lld` as the linker.
ENV RUSTFLAGS="-C link-arg=-fuse-ld=lld"
# Building with build.rs requires the Git context to be available across volumes.
ENV GIT_DISCOVERY_ACROSS_FILESYSTEM=1
# Install Rust tools.
COPY rust-toolchain.toml .
RUN rustup show
RUN cargo install cargo-chef
###
# Plan recipe
FROM chef AS planner
# Copy files
COPY .cargo ./.cargo
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
# Prepare the recipe
RUN cargo chef prepare --recipe-path recipe.json
###
# Build recipe
FROM chef AS builder
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 cargo chef cook --release --all-targets --recipe-path recipe.json
###
# Builds the application
FROM builder AS built
# Copy files
COPY .cargo ./.cargo
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY .git ./.git
# Build the app
RUN cargo build --release --all-targets
###
# 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; \
apt-get install --assume-yes curl
# Install the engine
COPY --from=built /app/target/release/engine /usr/local/bin
ENTRYPOINT ["engine"]