Skip to content

Commit

Permalink
Python -> Rust
Browse files Browse the repository at this point in the history
  • Loading branch information
thueske committed Oct 16, 2024
1 parent e8d16f0 commit bae5031
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Der Build-Stage
FROM rust:1-slim AS builder
WORKDIR /app

Expand All @@ -10,7 +11,7 @@ RUN apt-get update && apt-get install -y musl-tools

# Setze das Target Triple basierend auf der Architektur
ARG TARGETARCH
ENV RUST_TARGET_TRIPLE=${TARGETARCH}
ENV RUST_TARGET_TRIPLE=""

# Mapping der Architektur zu den korrekten Rust Triple
RUN if [ "$TARGETARCH" = "amd64" ]; then \
Expand All @@ -23,6 +24,19 @@ RUN if [ "$TARGETARCH" = "amd64" ]; then \

# Der finale Stage, der das Ergebnis des Builds verwendet
FROM scratch
# Verwende das gleiche ARG wie im Build-Stage
ARG TARGETARCH
ENV RUST_TARGET_TRIPLE=""

# Setze das Triple erneut, damit es auch im finalen Stage verfügbar ist
RUN if [ "$TARGETARCH" = "amd64" ]; then \
export RUST_TARGET_TRIPLE=x86_64-unknown-linux-musl; \
elif [ "$TARGETARCH" = "arm64" ]; then \
export RUST_TARGET_TRIPLE=aarch64-unknown-linux-musl; \
fi

# Kopiere das gebaute Binary aus dem Build-Stage in das finale Image
COPY --from=builder /app/target/${RUST_TARGET_TRIPLE}/release/cronjoblistener /app/cronjoblistener

# Setze das Entry Point für den Container
ENTRYPOINT ["/app/cronjoblistener"]

0 comments on commit bae5031

Please sign in to comment.