mirror of
https://github.com/nestriness/nestri.git
synced 2025-12-12 08:45:38 +02:00
🐛 fix: Cache the runner image to reduce build time (#143)
This commit is contained in:
32
.github/workflows/runner.yml
vendored
32
.github/workflows/runner.yml
vendored
@@ -41,6 +41,14 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Setup Docker Buildx
|
name: Setup Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
-
|
||||||
|
name: Cache Docker layers
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: /tmp/.buildx-cache
|
||||||
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-buildx-
|
||||||
-
|
-
|
||||||
name: Build Docker image
|
name: Build Docker image
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
@@ -49,7 +57,14 @@ jobs:
|
|||||||
context: ./
|
context: ./
|
||||||
push: false
|
push: false
|
||||||
load: true
|
load: true
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
||||||
tags: nestri:runner
|
tags: nestri:runner
|
||||||
|
-
|
||||||
|
name: Move cache
|
||||||
|
run: |
|
||||||
|
rm -rf /tmp/.buildx-cache
|
||||||
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||||
|
|
||||||
build-docker-main:
|
build-docker-main:
|
||||||
name: Build image on main
|
name: Build image on main
|
||||||
@@ -83,6 +98,14 @@ jobs:
|
|||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
type=semver,pattern={{major}}
|
type=semver,pattern={{major}}
|
||||||
|
-
|
||||||
|
name: Cache Docker layers
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: /tmp/.buildx-cache
|
||||||
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-buildx-
|
||||||
-
|
-
|
||||||
name: Build Docker image
|
name: Build Docker image
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
@@ -90,5 +113,12 @@ jobs:
|
|||||||
file: containers/runner.Containerfile
|
file: containers/runner.Containerfile
|
||||||
context: ./
|
context: ./
|
||||||
push: true
|
push: true
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
-
|
||||||
|
name: Move cache
|
||||||
|
run: |
|
||||||
|
rm -rf /tmp/.buildx-cache
|
||||||
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||||
@@ -13,12 +13,19 @@ RUN pacman -Syu --noconfirm meson pkgconf cmake git gcc make rustup \
|
|||||||
|
|
||||||
# Setup stable rust toolchain #
|
# Setup stable rust toolchain #
|
||||||
RUN rustup default stable
|
RUN rustup default stable
|
||||||
# # Clone nestri source #
|
|
||||||
#Copy the whole repo inside the build container
|
|
||||||
COPY ./ /builder/nestri/
|
|
||||||
|
|
||||||
RUN cd /builder/nestri/packages/server/ && \
|
#Copy the whole repo inside the build container
|
||||||
cargo build --release
|
# COPY ./ /builder/nestri/
|
||||||
|
|
||||||
|
RUN mkdir -p /artifacts
|
||||||
|
|
||||||
|
RUN --mount=type=bind,target=/builder/nestri/,rw \
|
||||||
|
--mount=type=cache,target=/builder/nestri/target/ \
|
||||||
|
--mount=type=cache,target=/usr/local/cargo/git/db \
|
||||||
|
--mount=type=cache,target=/usr/local/cargo/registry/ \
|
||||||
|
cd /builder/nestri/packages/server/ \
|
||||||
|
&& cargo build --release \
|
||||||
|
&& cp /builder/nestri/target/release/nestri-server /artifacts/
|
||||||
|
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
# gstwayland-builder
|
# gstwayland-builder
|
||||||
@@ -33,15 +40,28 @@ RUN pacman -Syu --noconfirm meson pkgconf cmake git gcc make rustup \
|
|||||||
# Setup stable rust toolchain #
|
# Setup stable rust toolchain #
|
||||||
RUN rustup default stable
|
RUN rustup default stable
|
||||||
# Build required cargo-c package #
|
# Build required cargo-c package #
|
||||||
RUN cargo install cargo-c
|
RUN --mount=type=cache,target=/usr/local/cargo/git/db \
|
||||||
|
--mount=type=cache,target=/usr/local/cargo/registry/ \
|
||||||
|
--mount=type=cache,target=/root/.cargo/bin/ \
|
||||||
|
cargo install cargo-c
|
||||||
|
|
||||||
# Clone gst plugin source #
|
# Clone gst plugin source #
|
||||||
RUN git clone https://github.com/games-on-whales/gst-wayland-display.git
|
RUN git clone https://github.com/games-on-whales/gst-wayland-display.git
|
||||||
|
|
||||||
# Build gst plugin #
|
# Build gst plugin #
|
||||||
RUN mkdir plugin && \
|
RUN mkdir plugin
|
||||||
cd gst-wayland-display && \
|
|
||||||
cargo cinstall --prefix=/builder/plugin/
|
|
||||||
|
|
||||||
|
RUN mkdir -p /artifacts
|
||||||
|
|
||||||
|
WORKDIR /builder/gst-wayland-display
|
||||||
|
|
||||||
|
RUN --mount=type=cache,target=/builder/gst-wayland-display/target/ \
|
||||||
|
--mount=type=cache,target=/root/.cargo/bin/ \
|
||||||
|
--mount=type=cache,target=/builder/plugin/ \
|
||||||
|
--mount=type=cache,target=/usr/local/cargo/git/db \
|
||||||
|
--mount=type=cache,target=/usr/local/cargo/registry/ \
|
||||||
|
cargo cinstall --prefix=/builder/plugin/ \
|
||||||
|
&& cp -r /builder/plugin/ /artifacts/
|
||||||
|
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
# runtime
|
# runtime
|
||||||
@@ -63,7 +83,6 @@ RUN pacman -Syu --noconfirm --needed \
|
|||||||
# Clean up pacman cache
|
# Clean up pacman cache
|
||||||
paccache -rk1
|
paccache -rk1
|
||||||
|
|
||||||
|
|
||||||
## User ##
|
## User ##
|
||||||
# Create and setup user #
|
# Create and setup user #
|
||||||
ENV USER="nestri" \
|
ENV USER="nestri" \
|
||||||
@@ -90,13 +109,13 @@ RUN usermod -aG input root && usermod -aG input ${USER} && \
|
|||||||
## Copy files from builders ##
|
## Copy files from builders ##
|
||||||
# this is done here at end to not trigger full rebuild on changes to builder
|
# this is done here at end to not trigger full rebuild on changes to builder
|
||||||
# nestri
|
# nestri
|
||||||
COPY --from=gst-builder /builder/nestri/target/release/nestri-server /usr/bin/nestri-server
|
COPY --from=gst-builder /artifacts/nestri-server /usr/bin/nestri-server
|
||||||
# gstwayland
|
# gstwayland
|
||||||
COPY --from=gstwayland-builder /builder/plugin/include/libgstwaylanddisplay /usr/include/
|
COPY --from=gstwayland-builder /artifacts/plugin/include/libgstwaylanddisplay /usr/include/
|
||||||
COPY --from=gstwayland-builder /builder/plugin/lib/*libgstwayland* /usr/lib/
|
COPY --from=gstwayland-builder /artifacts/plugin/lib/*libgstwayland* /usr/lib/
|
||||||
COPY --from=gstwayland-builder /builder/plugin/lib/gstreamer-1.0/libgstwayland* /usr/lib/gstreamer-1.0/
|
COPY --from=gstwayland-builder /artifacts/plugin/lib/gstreamer-1.0/libgstwayland* /usr/lib/gstreamer-1.0/
|
||||||
COPY --from=gstwayland-builder /builder/plugin/lib/pkgconfig/gstwayland* /usr/lib/pkgconfig/
|
COPY --from=gstwayland-builder /artifacts/plugin/lib/pkgconfig/gstwayland* /usr/lib/pkgconfig/
|
||||||
COPY --from=gstwayland-builder /builder/plugin/lib/pkgconfig/libgstwayland* /usr/lib/pkgconfig/
|
COPY --from=gstwayland-builder /artifacts/plugin/lib/pkgconfig/libgstwayland* /usr/lib/pkgconfig/
|
||||||
|
|
||||||
## Copy scripts ##
|
## Copy scripts ##
|
||||||
COPY packages/scripts/ /etc/nestri/
|
COPY packages/scripts/ /etc/nestri/
|
||||||
|
|||||||
Reference in New Issue
Block a user