34 lines
714 B
Docker
34 lines
714 B
Docker
# ---- Étape 1 : Build ----
|
|
FROM rust:1.82-alpine AS builder
|
|
|
|
|
|
RUN apk add --no-cache musl-dev pkgconfig openssl-dev build-base
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
RUN rustup target add x86_64-unknown-linux-musl
|
|
|
|
COPY Cargo.toml Cargo.lock ./
|
|
RUN mkdir src && echo "fn main() {}" > src/main.rs
|
|
RUN cargo build --release --target x86_64-unknown-linux-musl
|
|
RUN rm -rf src
|
|
|
|
COPY src ./src
|
|
RUN cargo build --release --target x86_64-unknown-linux-musl
|
|
|
|
# ---- Étape 2 : Runtime ----
|
|
FROM alpine:3.20 AS runtime
|
|
|
|
RUN apk add --no-cache ca-certificates ffmpeg rsync yt-dlp openssh
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/src /app/api
|
|
|
|
RUN adduser -D appuser
|
|
USER appuser
|
|
|
|
EXPOSE 8080
|
|
|
|
CMD ["./api"] |