Last active
April 9, 2023 19:45
-
-
Save medigor/f1afc4d281e3bf24eddd7d88e36cddab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# source: https://t.me/rustlang_ru/368839 | |
FROM debian:buster-slim AS base | |
RUN apt-get update \ | |
&& apt-get install -y --no-install-recommends \ | |
libpq5 \ | |
&& rm -rf /var/lib/apt/lists/* | |
WORKDIR /app | |
EXPOSE 8081 | |
FROM rust:1.49.0-buster AS build | |
WORKDIR /usr/src/app | |
RUN USER=root cargo init | |
COPY ./Cargo.toml . | |
COPY ./Cargo.lock . | |
RUN cargo build --release | |
COPY ./src ./src | |
COPY ./resources ./resources | |
# https://users.rust-lang.org/t/dockerfile-with-cached-dependencies-does-not-recompile-the-main-rs-file/21577 | |
RUN touch src/main.rs && cargo build --release | |
FROM base AS final | |
WORKDIR /app | |
COPY --from=build /usr/src/app/target/release/demo-api . | |
COPY --from=build /usr/src/app/resources/static ./resources/static | |
ENV RUST_BACKTRACE=full | |
ENTRYPOINT ["/app/demo-api"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment