-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
35 additions
and
12 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,24 +1,47 @@ | ||
# Use a specific version of clux/muslrust | ||
FROM --platform=linux/amd64 clux/muslrust:stable AS builder | ||
# ---- Builder Stage ---- | ||
FROM --platform=linux/amd64 rust:1.81 AS builder | ||
Check warning on line 2 in Dockerfile
|
||
|
||
# Install additional build dependencies required by aws-lc-sys | ||
RUN apt-get update && \ | ||
apt-get install -y \ | ||
cmake \ | ||
pkg-config \ | ||
git \ | ||
build-essential \ | ||
ninja-build \ | ||
python3 \ | ||
libssl-dev \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
RUN ln -s /usr/bin/ar /usr/bin/musl-ar | ||
ARG SQLX_OFFLINE | ||
ENV SQLX_OFFLINE=${SQLX_OFFLINE} | ||
|
||
WORKDIR /wld-usernames | ||
# Copy the entire source code into the container | ||
COPY . . | ||
|
||
ENV AR=musl-ar | ||
# Build the application in release mode | ||
RUN cargo build --release --bin wld-usernames | ||
|
||
ARG SQLX_OFFLINE | ||
ENV SQLX_OFFLINE=${SQLX_OFFLINE} | ||
# ---- Runtime Stage ---- | ||
FROM --platform=linux/amd64 debian:bookworm-slim AS runtime | ||
Check warning on line 29 in Dockerfile
|
||
|
||
RUN cargo build --release --bin wld-usernames | ||
# Install runtime dependencies (CA certificates and libssl3 for OpenSSL 3) | ||
RUN apt-get update && \ | ||
apt-get install -y ca-certificates libssl3 && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Set the working directory in the runtime container | ||
WORKDIR /app | ||
|
||
FROM --platform=linux/amd64 alpine AS runtime | ||
WORKDIR /wld-usernames | ||
COPY --from=builder /wld-usernames/target/x86_64-unknown-linux-musl/release/wld-usernames /usr/local/bin | ||
# Copy the built binary from the builder stage | ||
COPY --from=builder /app/target/release/wld-usernames /usr/local/bin/wld-usernames | ||
|
||
# Expose the port your server listens on | ||
EXPOSE 8000 | ||
ENTRYPOINT ["/usr/local/bin/wld-usernames"] | ||
|
||
HEALTHCHECK --interval=5m \ | ||
CMD curl -f http://localhost:8000/ || exit 1 | ||
CMD curl -f http://localhost:8000/ || exit 1 |