mirror-server/Dockerfile

38 lines
788 B
Docker
Raw Normal View History

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 .
COPY ["Cargo.toml", "./"]
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}