mirror of
				https://github.com/blakeblackshear/frigate.git
				synced 2025-10-27 10:52:11 +01:00 
			
		
		
		
	Integrate ccache into libusb and nginx build scripts for improved build speed (#6886)
* Add ccache to libusb and nginx build scripts * Add ccache support to Dockerfile for faster builds * Add ccache to PATH and use it for compiling nginx with Makefile in build_nginx.sh script
This commit is contained in:
		
							parent
							
								
									d51197eaa2
								
							
						
					
					
						commit
						b6fce8f0bb
					
				
							
								
								
									
										11
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								Dockerfile
									
									
									
									
									
								
							@ -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,14 +64,16 @@ 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
 | 
					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 --disable-udev --enable-shared && \
 | 
					    ./configure CC='ccache gcc' CCX='ccache g++' --disable-udev --enable-shared && \
 | 
				
			||||||
    make -j $(nproc --all)
 | 
					    make -j $(nproc --all)
 | 
				
			||||||
RUN apt-get update && \
 | 
					RUN apt-get update && \
 | 
				
			||||||
    apt-get install -y --no-install-recommends libusb-1.0-0-dev && \
 | 
					    apt-get install -y --no-install-recommends libusb-1.0-0-dev && \
 | 
				
			||||||
 | 
				
			|||||||
@ -15,6 +15,10 @@ apt-get -yqq build-dep nginx
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
apt-get -yqq install --no-install-recommends ca-certificates wget
 | 
					apt-get -yqq install --no-install-recommends ca-certificates wget
 | 
				
			||||||
update-ca-certificates -f
 | 
					update-ca-certificates -f
 | 
				
			||||||
 | 
					apt install -y ccache
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export PATH="/usr/lib/ccache:$PATH"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
mkdir /tmp/nginx
 | 
					mkdir /tmp/nginx
 | 
				
			||||||
wget -nv https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
 | 
					wget -nv https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
 | 
				
			||||||
tar -zxf nginx-${NGINX_VERSION}.tar.gz -C /tmp/nginx --strip-components=1
 | 
					tar -zxf nginx-${NGINX_VERSION}.tar.gz -C /tmp/nginx --strip-components=1
 | 
				
			||||||
@ -62,5 +66,5 @@ cd /tmp/nginx
 | 
				
			|||||||
    --add-module=../nginx-rtmp-module \
 | 
					    --add-module=../nginx-rtmp-module \
 | 
				
			||||||
    --with-cc-opt="-O3 -Wno-error=implicit-fallthrough"
 | 
					    --with-cc-opt="-O3 -Wno-error=implicit-fallthrough"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
make -j$(nproc) && make install
 | 
					make CC="ccache gcc" -j$(nproc) && make install
 | 
				
			||||||
rm -rf /usr/local/nginx/html /usr/local/nginx/conf/*.default
 | 
					rm -rf /usr/local/nginx/html /usr/local/nginx/conf/*.default
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user