mirror-server/Dockerfile

36 lines
788 B
Docker
Raw Normal View History

FROM rust:1.76-buster 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 .
COPY ["Cargo.toml", "./"]
RUN cargo build \
&& cargo build --tests \
&& cargo build --release \
&& rm src/*.rs
# Bring in the source
COPY ["./src/*", "./src/"]
2024-02-24 12:38:29 -05:00
COPY ["README.md", "LICENSE", "."]
# 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
COPY --from=BUILD ${APP_HOME}/target/release/${APP_NAME} /usr/local/bin/
CMD ${APP_NAME}