Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(build): Stop using cargo-chef #169

Merged
merged 1 commit into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
# syntax=docker/dockerfile:1.7-labs

FROM lukemathwalker/cargo-chef:0.1.68-rust-alpine AS chef
FROM rust:alpine AS build
WORKDIR /usr/src/prose-pod-api


FROM chef AS planner
COPY --exclude=crates/*/static/ . .
RUN cargo chef prepare --recipe-path recipe.json


FROM chef AS builder
COPY --from=planner /usr/src/prose-pod-api/recipe.json recipe.json
RUN apk update && apk add musl-dev

ARG CARGO_PROFILE='release'

# Build the dependencies (and use Docker’s cache to avoid rebuilding it next time).
ARG CARGO_CHEF_EXTRA_ARGS=''
RUN cargo chef cook --profile="${CARGO_PROFILE}" --recipe-path recipe.json ${CARGO_CHEF_EXTRA_ARGS}

# Build the application.
COPY --exclude=crates/*/static/ . .
ARG CARGO_INSTALL_EXTRA_ARGS=''
Expand Down Expand Up @@ -48,7 +36,7 @@ RUN apk update && apk add libgcc libc6-compat

WORKDIR /usr/share/prose-pod-api

COPY --from=builder /usr/local/cargo/bin/prose-pod-api /usr/local/bin/prose-pod-api
COPY --from=build /usr/local/cargo/bin/prose-pod-api /usr/local/bin/prose-pod-api
COPY --from=api-docs /usr/share/prose-pod-api/static /usr/share/prose-pod-api/static

CMD ["prose-pod-api"]
Expand Down
3 changes: 0 additions & 3 deletions scripts/build-image
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ help() {

# ===== ARGUMENT PARSING =====

CARGO_CHEF_EXTRA_ARGS=()
CARGO_INSTALL_EXTRA_ARGS=()
CARGO_PROFILE=release
unset NO_PULL
Expand All @@ -93,7 +92,6 @@ for arg in "$@"; do
--offline)
die "Offline builds are not supported anymore, because we build the Rust project in a Dockerfile and we have a git dependency ($(format_code prose-core-client)). If you need this feature, consider adding $(format_code prose-core-client) as a $(format_hyperlink 'git submodule' 'https://git-scm.com/book/en/v2/Git-Tools-Submodules') instead."
info 'Will build without accesing the network.'
CARGO_CHEF_EXTRA_ARGS+=('--offline')
CARGO_INSTALL_EXTRA_ARGS+=('--offline')
info 'Will not pull referenced Docker images.'
NO_PULL=1
Expand Down Expand Up @@ -137,7 +135,6 @@ edo docker buildx build \
${DOCKER_TARGET_PLATFORM:+--platform "${DOCKER_TARGET_PLATFORM:?}"} \
-t "${PROSE_POD_API_IMAGE:?}" \
${CARGO_PROFILE:+--build-arg CARGO_PROFILE="${CARGO_PROFILE}"} \
${CARGO_CHEF_EXTRA_ARGS:+--build-arg CARGO_CHEF_EXTRA_ARGS="${CARGO_CHEF_EXTRA_ARGS[*]}"} \
${CARGO_INSTALL_EXTRA_ARGS:+--build-arg CARGO_INSTALL_EXTRA_ARGS="${CARGO_INSTALL_EXTRA_ARGS[*]}"} \
--build-arg VERSION="${PROSE_POD_API_IMAGE_TAG:?}" \
--build-arg COMMIT="${COMMIT:-}" \
Expand Down
Loading