Skip to content

Commit

Permalink
cache apt
Browse files Browse the repository at this point in the history
  • Loading branch information
ngalaiko committed Feb 20, 2024
1 parent 349ffc5 commit 64471a8
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
FROM rust:1.74 as build

ENV DEBIAN_FRONTEND=noninteractive
RUN --mount=type=cache,target=/var/lib/apt/lists,sharing=locked \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
rm -f /etc/apt/apt.conf.d/docker-clean \
&& apt-get update \
&& apt-get -y --no-install-recommends install musl-tools=1.2.3-1

ENV CARGO_BUILD_TARGET=x86_64-unknown-linux-musl \
DEBIAN_FRONTEND=noninteractive \
PKG_CONFIG_ALLOW_CROSS=1
PKG_CONFIG_ALLOW_CROSS=1

WORKDIR /app

COPY . .

RUN --mount=type=cache,target=/app/target \
--mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=/usr/local/rustup \
apt-get update \
&& apt-get -y --no-install-recommends install musl-tools \
&& rustup install stable \
--mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=/usr/local/rustup \
rustup install stable \
&& rustup target add ${CARGO_BUILD_TARGET} \
&& cargo build --package serve --release \
&& cargo build --package serve --release \
&& mkdir -p /build \
&& cp /app/target/${CARGO_BUILD_TARGET}/release/serve /build/ \
&& strip /build/serve
Expand Down

0 comments on commit 64471a8

Please sign in to comment.