Add ccache support to Dockerfile for faster builds

This commit is contained in:
Sergey Krashevich 2023-06-22 20:10:52 +03:00
parent 3aba9d26b3
commit 4882c12c9f
No known key found for this signature in database
GPG Key ID: 625171324E7D3856

View File

@ -18,10 +18,13 @@ WORKDIR /rootfs
FROM base AS nginx FROM base AS nginx
ARG DEBIAN_FRONTEND ARG DEBIAN_FRONTEND
ENV CCACHE_DIR /root/.ccache
ENV CCACHE_MAXSIZE 2G
# bind /var/cache/apt to tmpfs to speed up nginx build # bind /var/cache/apt to tmpfs to speed up nginx build
RUN --mount=type=tmpfs,target=/tmp --mount=type=tmpfs,target=/var/cache/apt \ RUN --mount=type=tmpfs,target=/tmp --mount=type=tmpfs,target=/var/cache/apt \
--mount=type=bind,source=docker/build_nginx.sh,target=/deps/build_nginx.sh \ --mount=type=bind,source=docker/build_nginx.sh,target=/deps/build_nginx.sh \
--mount=type=cache,target=/root/.ccache \
/deps/build_nginx.sh /deps/build_nginx.sh
FROM wget AS go2rtc FROM wget AS go2rtc
@ -61,11 +64,13 @@ RUN mkdir /models \
FROM wget as libusb-build FROM wget as libusb-build
ARG TARGETARCH ARG TARGETARCH
ARG DEBIAN_FRONTEND ARG DEBIAN_FRONTEND
ENV CCACHE_DIR /root/.ccache
ENV CCACHE_MAXSIZE 2G
# Build libUSB without udev. Needed for Openvino NCS2 support # Build libUSB without udev. Needed for Openvino NCS2 support
WORKDIR /opt WORKDIR /opt
RUN apt-get update && apt-get install -y unzip build-essential automake libtool ccache RUN apt-get update && apt-get install -y unzip build-essential automake libtool ccache
RUN wget -q https://github.com/libusb/libusb/archive/v1.0.25.zip -O v1.0.25.zip && \ RUN --mount=type=cache,target=/root/.ccache wget -q https://github.com/libusb/libusb/archive/v1.0.25.zip -O v1.0.25.zip && \
unzip v1.0.25.zip && cd libusb-1.0.25 && \ unzip v1.0.25.zip && cd libusb-1.0.25 && \
./bootstrap.sh && \ ./bootstrap.sh && \
./configure CC='ccache gcc' CCX='ccache g++' --disable-udev --enable-shared && \ ./configure CC='ccache gcc' CCX='ccache g++' --disable-udev --enable-shared && \