Faster image builds with caching (#4491)

* fix makefile variable

* add branch for testing

* fix arm32 build

* use amd64 for web build

* install wheels in a separate layer for better parallel builds

* try build-push-action

* try using gh context

* use short sha

* cleanup
This commit is contained in:
Blake Blackshear
2022-11-23 20:00:45 -06:00
committed by GitHub
parent f4187d6b83
commit 370276a7b6
4 changed files with 23 additions and 21 deletions

View File

@@ -41,6 +41,7 @@ RUN --mount=type=bind,source=docker/install_s6_overlay.sh,target=/deps/install_s
FROM base AS wheels
ARG DEBIAN_FRONTEND
ARG TARGETARCH
# Use a separate container to build wheels to prevent build dependencies in final image
RUN apt-get -qq update \
@@ -106,9 +107,11 @@ ENV PATH="/usr/lib/btbn-ffmpeg/bin:/usr/local/go2rtc/bin:/usr/local/nginx/sbin:$
# Install dependencies
RUN --mount=type=bind,source=docker/install_deps.sh,target=/deps/install_deps.sh \
--mount=type=bind,from=wheels,source=/wheels,target=/deps/wheels \
/deps/install_deps.sh
RUN --mount=type=bind,from=wheels,source=/wheels,target=/deps/wheels \
pip3 install -U /deps/wheels/*.whl
COPY --from=deps-rootfs / /
EXPOSE 5000
@@ -118,8 +121,8 @@ EXPOSE 8555
ENTRYPOINT ["/init"]
# Frigate deps with Node.js and NPM
FROM deps AS deps-node
# Frigate deps with Node.js and NPM for devcontainer
FROM deps AS devcontainer
# Install Node 16
RUN apt-get update \
@@ -129,9 +132,6 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/* \
&& npm install -g npm@9
# Devcontainer
FROM deps-node AS devcontainer
WORKDIR /workspace/frigate
RUN apt-get update \
@@ -145,7 +145,8 @@ CMD ["sleep", "infinity"]
# Frigate web build
FROM deps-node AS web-build
# force this to run on amd64 because QEMU is painfully slow
FROM --platform=linux/amd64 node:16 AS web-build
WORKDIR /work
COPY web/package.json web/package-lock.json ./
@@ -154,19 +155,13 @@ RUN npm install
COPY web/ ./
RUN npm run build
# Frigate web dist files
FROM scratch AS web-dist
COPY --from=web-build /work/dist/ /
# Collect final files in a single layer
FROM scratch AS rootfs
WORKDIR /opt/frigate/
COPY frigate frigate/
COPY migrations migrations/
COPY --from=web-dist / web/
COPY --from=web-build /work/dist/ web/
# Frigate final container
FROM deps