FROM ghcr.io/rivet-dev/rivet/engine-base-builder:a36b881 AS builder
ARG TARGETARCH
ARG CARGO_BUILD_MODE=debug
ARG STRIP_BINARY=false
ARG OVERRIDE_GIT_SHA
WORKDIR /app
COPY . .
RUN RUST_TOOLCHAIN="$(sed -n 's/^channel = "\(.*\)"$/\1/p' rust-toolchain.toml)" && \
rustup toolchain install "${RUST_TOOLCHAIN}" --profile minimal && \
rustup default "${RUST_TOOLCHAIN}"
RUN \
--mount=type=secret,id=netrc,target=/root/.netrc,mode=0600 \
--mount=type=cache,target=/usr/local/cargo/git,id=univseral-cargo-git \
--mount=type=cache,target=/usr/local/cargo/registry,id=univseral-cargo-registry \
--mount=type=cache,target=/app/target,id=univseral-target \
--mount=type=cache,target=/root/.cache,id=universal-user-cache \
if [ "$CARGO_BUILD_MODE" = "release" ]; then \
RUSTFLAGS="--cfg tokio_unstable" cargo build -p rivet-engine --bin rivet-engine --release; \
else \
RUSTFLAGS="--cfg tokio_unstable" cargo build -p rivet-engine --bin rivet-engine; \
fi && \
mkdir /app/dist/ && \
echo "Copying binary" && \
cp target/$CARGO_BUILD_MODE/rivet-engine /app/dist/ && \
if [ "$STRIP_BINARY" = "true" ]; then strip /app/dist/rivet-engine; fi
FROM ghcr.io/rivet-dev/rivet/engine-base-runtime-full:a36b881 AS engine-full-base
FROM engine-full-base AS engine-full
LABEL org.opencontainers.image.source=https://github.com/rivet-dev/rivet
COPY --from=builder /app/dist/rivet-engine /usr/bin/rivet-engine
ENTRYPOINT ["/usr/bin/rivet-engine"]
FROM ghcr.io/rivet-dev/rivet/engine-base-runtime-slim:a36b881 AS engine-slim
LABEL org.opencontainers.image.source=https://github.com/rivet-dev/rivet
COPY --from=builder /app/dist/rivet-engine /usr/bin/rivet-engine
ENTRYPOINT ["/usr/bin/rivet-engine"]