# Build stage
FROM rust:alpine AS builder
RUN apk add --no-cache pkgconfig
RUN apk add --no-cache openssl-dev musl-dev
RUN apk add --no-cache openssl-libs-static
ARG build="cargo build --release"
COPY Cargo.toml /app/Cargo.toml
COPY src /app/src
WORKDIR "/app"
RUN $build

# Runtime stage
FROM alpine:latest
RUN apk add --no-cache libgcc
RUN apk add --no-cache openssl-libs-static
ARG binary="/app/target/release/client"
ARG target="/usr/local/bin/client"
COPY --from=builder $binary $target
WORKDIR "/root"
CMD ["client"]
