2024-02-21 23:17:17 -05:00
|
|
|
FROM rust:1.76 AS BUILD
|
|
|
|
|
|
|
|
ENV APP_NAME=mirror-server
|
|
|
|
ENV APP_HOME=/srv/${APP_NAME}
|
|
|
|
RUN apt update \
|
|
|
|
&& apt install -y curl \
|
|
|
|
&& cargo install cargo-deb
|
|
|
|
|
|
|
|
# Setup working env.
|
|
|
|
RUN mkdir -p ${APP_HOME}
|
|
|
|
WORKDIR ${APP_HOME}
|
|
|
|
|
|
|
|
# Create build target cache.
|
|
|
|
RUN USER=root cargo init --bin .
|
2024-02-21 23:42:24 -05:00
|
|
|
COPY ["Cargo.toml", "./"]
|
2024-02-21 23:17:17 -05:00
|
|
|
RUN cargo build \
|
|
|
|
&& cargo build --tests \
|
|
|
|
&& cargo build --release \
|
|
|
|
&& rm src/*.rs
|
|
|
|
|
|
|
|
# Bring in the source
|
|
|
|
COPY ["src", "./src/"]
|
|
|
|
|
|
|
|
# Build the example API.
|
|
|
|
RUN cargo build --release
|
|
|
|
|
|
|
|
# Create the minimal server image.
|
|
|
|
FROM debian:buster-slim AS SERVER
|
|
|
|
|
|
|
|
ENV APP_NAME=mirror-server
|
|
|
|
ENV APP_HOME=/srv/${APP_NAME}
|
|
|
|
RUN apt update
|
|
|
|
|
|
|
|
RUN mkdir -p ${APP_HOME}
|
|
|
|
WORKDIR ${APP_HOME}
|
|
|
|
|
|
|
|
COPY --from=BUILD ${APP_HOME}/target/release/${APP_NAME} /usr/local/bin/
|
|
|
|
CMD ${APP_NAME}
|