Speed up CI, Reduce container image size (#591)
* Action: Add rust caching to test * Actions: Use github action to cache docker * Optimize Dockerfile to allow for caching * Docker: Use cargo chef for caching Co-authored-by: Luigi311 <luigi311.lg@gmail.com>
This commit is contained in:
parent
b0bb4687ee
commit
fe137408c9
26
.github/workflows/tests.yml
vendored
26
.github/workflows/tests.yml
vendored
|
@ -12,6 +12,9 @@ jobs:
|
|||
container: shssoichiro/av1an-ci:latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
|
||||
- name: Validate encoders
|
||||
run: |
|
||||
which aomenc
|
||||
|
@ -248,20 +251,12 @@ jobs:
|
|||
file: ./Dockerfile
|
||||
push: false
|
||||
tags: av1an:action
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha, mode=max
|
||||
|
||||
- name: Image digest
|
||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||
|
||||
- name: Tar docker cache
|
||||
run: tar -cf /tmp/docker-cache.tar /tmp/.buildx-cache
|
||||
|
||||
- name: Artifact docker cache
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: docker-cache
|
||||
path: /tmp/docker-cache.tar
|
||||
|
||||
docker-publish:
|
||||
needs: [all-tests, docker]
|
||||
runs-on: ubuntu-latest
|
||||
|
@ -270,14 +265,6 @@ jobs:
|
|||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: docker-cache
|
||||
path: /tmp/
|
||||
|
||||
- name: Extract docker cache
|
||||
run: tar -xf /tmp/docker-cache.tar -C /
|
||||
|
||||
- name: Docker meta
|
||||
id: docker_meta
|
||||
uses: crazy-max/ghaction-docker-meta@v1
|
||||
|
@ -306,7 +293,8 @@ jobs:
|
|||
push: true
|
||||
tags: ${{ steps.docker_meta.outputs.tags }}
|
||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
- name: Image digest
|
||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||
|
|
79
Dockerfile
79
Dockerfile
|
@ -1,36 +1,71 @@
|
|||
FROM archlinux:base-devel
|
||||
FROM archlinux:base-devel AS planner
|
||||
RUN pacman -Syy --noconfirm
|
||||
|
||||
ENV MPLCONFIGDIR="/home/app_user/"
|
||||
ARG DEPENDENCIES="mkvtoolnix curl llvm clang"
|
||||
# Install all dependencies (except for rav1e)
|
||||
RUN pacman -S --noconfirm rsync rust clang nasm git aom ffmpeg vapoursynth ffms2 libvpx mkvtoolnix-cli svt-av1 vapoursynth-plugin-lsmashsource vmaf
|
||||
|
||||
WORKDIR /tmp/Av1an
|
||||
RUN cargo install cargo-chef
|
||||
COPY . .
|
||||
RUN cargo chef prepare --recipe-path recipe.json
|
||||
|
||||
|
||||
|
||||
|
||||
FROM archlinux:base-devel AS cacher
|
||||
RUN pacman -Syy --noconfirm
|
||||
|
||||
# Install all dependencies (except for rav1e)
|
||||
RUN pacman -S --noconfirm rsync rust clang nasm git aom ffmpeg vapoursynth ffms2 libvpx mkvtoolnix-cli svt-av1 vapoursynth-plugin-lsmashsource vmaf
|
||||
|
||||
WORKDIR /tmp/Av1an
|
||||
RUN cargo install cargo-chef
|
||||
COPY --from=planner /tmp/Av1an/recipe.json recipe.json
|
||||
RUN cargo chef cook --release --recipe-path recipe.json
|
||||
|
||||
|
||||
|
||||
|
||||
FROM archlinux:base-devel AS build
|
||||
|
||||
RUN pacman -Syy --noconfirm
|
||||
|
||||
# Install make dependencies
|
||||
RUN pacman -S --noconfirm rust clang nasm git
|
||||
# Install all dependencies (except for rav1e)
|
||||
RUN pacman -S --noconfirm rsync rust clang nasm git aom ffmpeg vapoursynth ffms2 libvpx mkvtoolnix-cli svt-av1 vapoursynth-plugin-lsmashsource vmaf
|
||||
|
||||
# Compile rav1e from git, as archlinux is still on rav1e 0.4
|
||||
RUN git clone https://github.com/xiph/rav1e /tmp/rav1e
|
||||
WORKDIR /tmp/rav1e
|
||||
RUN cargo build --release && \
|
||||
strip ./target/release/rav1e
|
||||
RUN mv ./target/release/rav1e /usr/local/bin
|
||||
|
||||
# Build av1an
|
||||
COPY . /tmp/Av1an
|
||||
|
||||
# Copy over the cached dependencies
|
||||
COPY --from=cacher /tmp/Av1an/target /tmp/Av1an/target
|
||||
|
||||
WORKDIR /tmp/Av1an
|
||||
RUN cargo build --release
|
||||
RUN mv ./target/release/av1an /usr/local/bin
|
||||
|
||||
|
||||
|
||||
FROM archlinux:base-devel AS runtime
|
||||
|
||||
ENV MPLCONFIGDIR="/home/app_user/"
|
||||
|
||||
RUN pacman -Syy --noconfirm
|
||||
|
||||
# Install all optional dependencies (except for rav1e)
|
||||
RUN pacman -S --noconfirm aom ffmpeg vapoursynth ffms2 libvpx mkvtoolnix-cli svt-av1 vapoursynth-plugin-lsmashsource vmaf
|
||||
|
||||
# Compile rav1e from git, as archlinux is still on rav1e 0.4
|
||||
RUN git clone https://github.com/xiph/rav1e && \
|
||||
cd rav1e && \
|
||||
cargo build --release && \
|
||||
strip ./target/release/rav1e && \
|
||||
mv ./target/release/rav1e /usr/local/bin && \
|
||||
cd .. && rm -rf ./rav1e
|
||||
COPY --from=build /usr/local/bin/rav1e /usr/local/bin/rav1e
|
||||
COPY --from=build /usr/local/bin/av1an /usr/local/bin/av1an
|
||||
|
||||
# Create user
|
||||
RUN useradd -ms /bin/bash app_user
|
||||
|
||||
# Copy av1an and build av1an
|
||||
COPY --chown=app_user . /Av1an
|
||||
WORKDIR /Av1an
|
||||
RUN cargo build --release && \
|
||||
mv ./target/release/av1an /usr/local/bin && \
|
||||
cd .. && rm -rf ./Av1an
|
||||
|
||||
# Remove build dependencies
|
||||
RUN pacman -R --noconfirm rust clang nasm git
|
||||
USER app_user
|
||||
|
||||
VOLUME ["/videos"]
|
||||
|
|
Loading…
Reference in a new issue