This repository has been archived by the owner on Aug 21, 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.
- Loading branch information
Showing
3 changed files
with
87 additions
and
59 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.dockerignore | ||
.env | ||
.git* | ||
.idea | ||
.vscode | ||
Containerfile | ||
migrations | ||
scripts | ||
target | ||
tests |
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
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
FROM docker.io/lukemathwalker/cargo-chef:0.1.63-rust-1.76.0-bookworm as chef | ||
LABEL stage=build | ||
|
||
RUN apt-get update \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y clang libssl-dev lld pkg-config \ | ||
&& groupadd -g 1000 app \ | ||
&& useradd -u 1000 -g 1000 -s /bin/bash -M app \ | ||
&& mkdir /app \ | ||
&& chown app:app /app | ||
|
||
FROM chef AS planner | ||
LABEL stage=build | ||
|
||
USER app | ||
|
||
WORKDIR /app | ||
COPY --chown=app:app . . | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
|
||
FROM planner AS builder | ||
LABEL stage=build | ||
|
||
ENV SQLX_OFFLINE true | ||
USER app | ||
|
||
COPY --from=planner --chown=app:app /app/recipe.json . | ||
RUN cargo chef cook --release --recipe-path recipe.json | ||
|
||
COPY --chown=app:app . . | ||
RUN cargo build --release | ||
|
||
FROM docker.io/library/debian:bookworm-slim AS runtime | ||
|
||
RUN apt-get update \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y ca-certificates libssl3 \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& groupadd -g 1000 app \ | ||
&& useradd -u 1000 -g 1000 -s /bin/bash -M app | ||
|
||
ENV APP_ENVIRONMENT production | ||
USER app | ||
|
||
WORKDIR /app | ||
COPY --chown=root:root --chmod=444 configuration ./configuration | ||
COPY --from=builder --chown=root:root --chmod=555 /app/target/release/zero2prod . | ||
|
||
ENTRYPOINT ["./zero2prod"] |