-
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.
Merge pull request #47 from renegade-fi/joey/auth-server-docker
auth-server: Dockerfile: Add dockerfile
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 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,56 @@ | ||
# === Chef === # | ||
FROM --platform=arm64 rust:latest AS chef | ||
|
||
# Create a build dir and add local dependencies | ||
WORKDIR /build | ||
|
||
COPY ./rust-toolchain ./rust-toolchain | ||
RUN cat rust-toolchain | xargs rustup toolchain install | ||
|
||
# Install cargo-chef | ||
RUN cargo install cargo-chef | ||
|
||
# === Sources === # | ||
FROM chef AS sources | ||
WORKDIR /build | ||
COPY ./Cargo.toml ./Cargo.lock ./ | ||
COPY ./auth-server ./auth-server | ||
|
||
# === Builder === # | ||
# Pull the sources into their own layer | ||
FROM chef AS builder | ||
|
||
# Disable compiler warnings and enable backtraces for panic debugging | ||
ENV RUSTFLAGS=-Awarnings | ||
ENV RUST_BACKTRACE=1 | ||
ENV CARGO_HTTP_CHECK_REVOKE=false | ||
|
||
COPY --from=sources /build /build | ||
WORKDIR /build | ||
|
||
# Install protoc, openssl, and pkg-config | ||
RUN apt-get update && \ | ||
apt-get install -y pkg-config libssl-dev libclang-dev libpq-dev ca-certificates | ||
|
||
# Update Cargo.toml to include only "auth-server" in workspace members | ||
RUN sed -i '/members[[:space:]]*=[[:space:]]*\[/,/\]/c\members = ["auth-server"]' Cargo.toml | ||
RUN cargo chef prepare --recipe-path recipe.json --bin auth-server | ||
|
||
# Build only the dependencies to cache them in this layer | ||
RUN cargo chef cook --release --recipe-path recipe.json | ||
|
||
COPY --from=sources /build/auth-server /build/auth-server | ||
WORKDIR /build | ||
|
||
RUN cargo build --release -p auth-server | ||
|
||
# === Release stage === # | ||
FROM --platform=arm64 debian:bookworm-slim | ||
RUN apt-get update && \ | ||
apt-get install -y libssl-dev ca-certificates libpq-dev | ||
|
||
# Copy the binary from the build stage | ||
COPY --from=builder /build/target/release/auth-server /bin/auth-server | ||
|
||
ENTRYPOINT ["/bin/auth-server"] | ||
CMD ["--datadog-logging"] |
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