optimize dockerfile

main
overlisted 1 month ago
parent a43abe0491
commit 9fbfcd276e
Signed by: me
GPG Key ID: 1ACCDCC0429C9737
  1. 16
      Dockerfile

@ -1,11 +1,17 @@
FROM rustlang/rust:nightly-slim
RUN apt update; apt install -y libpq-dev
# syntax=docker/dockerfile:1.4
FROM rustlang/rust:nightly-slim AS builder
RUN apt update; apt install -y libpq-dev
WORKDIR /code
COPY . .
RUN cargo build -r; mv ./target/release/mango /mango; rm -rf ./target
RUN --mount=type=cache,target=/usr/local/cargo/registry --mount=type=cache,target=/code/target \
cargo build -r; mv ./target/release/mango ./mango
EXPOSE 8000
CMD /mango
FROM ubuntu
RUN apt update; apt install -y libpq-dev
COPY . .
COPY --from=builder /code/mango /
CMD /mango
EXPOSE 8000
LABEL org.opencontainers.image.source https://github.com/overlisted/mango

Loading…
Cancel
Save