This repository has been archived by the owner on Sep 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
swap Dockerfile to prevent DO out-of-memory error
- Loading branch information
Showing
1 changed file
with
8 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,26 @@ | ||
# Builder stage | ||
## Use the latest Rust stable release as base image | ||
FROM lukemathwalker/cargo-chef:latest-rust-1.53.0 AS planner | ||
FROM lukemathwalker/cargo-chef:latest-rust-1.53.0 as chef | ||
WORKDIR /app | ||
|
||
FROM chef as planner | ||
COPY . . | ||
# Generate a 'lock' file for our project | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
|
||
FROM lukemathwalker/cargo-chef:latest-rust-1.53.0 AS cacher | ||
WORKDIR /app | ||
FROM chef as builder | ||
COPY --from=planner /app/recipe.json recipe.json | ||
RUN cargo chef cook --release --recipe-path recipe.json | ||
|
||
FROM rust:1.53.0 AS builder | ||
WORKDIR /app | ||
# Cpopy over the cached dependencies | ||
COPY --from=cacher /app/target target | ||
COPY --from=cacher /usr/local/cargo /usr/local/cargo | ||
COPY . . | ||
ENV SQLX_OFFLINE true | ||
# Build application, with deps already cached :) | ||
RUN cargo build --release --bin zerotoprod | ||
RUN cargo build --release --bin zero2prod | ||
|
||
# Runtime stage | ||
FROM debian:buster-slim AS runtime | ||
WORKDIR /app | ||
# Install OpenSSL - it is dynamically linked by some of our dependencies | ||
RUN apt-get update -y \ | ||
&& apt-get install -y --no-install-recommends openssl \ | ||
# Clean up | ||
&& apt-get autoremove -y \ | ||
&& apt-get clean -y \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
COPY --from=builder /app/target/release/zerotoprod zerotoprod | ||
COPY --from=builder /app/target/release/zero2prod zero2prod | ||
COPY configuration configuration | ||
ENV APP_ENVIRONMENT production | ||
# Launch binary on execute of `docker run` | ||
ENTRYPOINT ["./zerotoprod"] | ||
ENTRYPOINT ["./zero2prod"] |