Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Commit

Permalink
swap Dockerfile to prevent DO out-of-memory error
Browse files Browse the repository at this point in the history
  • Loading branch information
paulroden committed Sep 6, 2021
1 parent 6e86279 commit 43ebe15
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions Dockerfile
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"]

0 comments on commit 43ebe15

Please sign in to comment.