From 9f7460c744278c3d37d6df06c6200bce684b3d42 Mon Sep 17 00:00:00 2001 From: Wojciech Kozyra Date: Mon, 8 Jan 2024 15:25:20 +0100 Subject: [PATCH] Add separate dockerfile without web renderer support --- .github/workflows/docker.yml | 8 ++++-- examples/docker.rs | 9 +++++- Dockerfile => full.Dockerfile | 0 slim.Dockerfile | 52 +++++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 3 deletions(-) rename Dockerfile => full.Dockerfile (100%) create mode 100644 slim.Dockerfile diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 892669518..84127b2a6 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -25,7 +25,11 @@ jobs: - uses: hadolint/hadolint-action@v3.1.0 with: - dockerfile: Dockerfile + dockerfile: slim.Dockerfile + + - uses: hadolint/hadolint-action@v3.1.0 + with: + dockerfile: full.Dockerfile - name: Build image - run: docker build -t video-compositor . + run: docker build -f slim.Dockerfile -t video-compositor . diff --git a/examples/docker.rs b/examples/docker.rs index 6fe93ec32..165cd2ae4 100644 --- a/examples/docker.rs +++ b/examples/docker.rs @@ -54,7 +54,14 @@ fn build_and_start_docker(skip_build: bool) -> Result<()> { if !skip_build { info!("[example] docker build"); let mut process = Command::new("docker") - .args(["build", "-t", "video-compositor", "."]) + .args([ + "build", + "-f", + "slim.Dockerfile", + "-t", + "video-compositor", + ".", + ]) .spawn()?; let exit_code = process.wait()?; if Some(0) != exit_code.code() { diff --git a/Dockerfile b/full.Dockerfile similarity index 100% rename from Dockerfile rename to full.Dockerfile diff --git a/slim.Dockerfile b/slim.Dockerfile new file mode 100644 index 000000000..76a1275ab --- /dev/null +++ b/slim.Dockerfile @@ -0,0 +1,52 @@ +# Builder image +FROM ubuntu:mantic-20231011 as builder + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +ARG USERNAME=compositor +ARG RUST_VERSION=1.74 + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -y -qq && \ + apt-get install -y \ + build-essential curl pkg-config libssl-dev libclang-dev git sudo \ + libegl1-mesa-dev libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers \ + ffmpeg libavcodec-dev libavformat-dev libavfilter-dev libavdevice-dev && \ + rm -rf /var/lib/apt/lists/* + +RUN curl https://sh.rustup.rs -sSf | bash -s -- -y +RUN source ~/.cargo/env && rustup install $RUST_VERSION && rustup default $RUST_VERSION + +COPY . /root/project +WORKDIR /root/project + +RUN source ~/.cargo/env && cargo build --release --no-default-features + +# Runtime image +FROM ubuntu:mantic-20231011 + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +ARG USERNAME=compositor + +ENV DEBIAN_FRONTEND=noninteractive +ENV NVIDIA_DRIVER_CAPABILITIES compute,graphics,utility + +RUN apt-get update -y -qq && \ + apt-get install -y \ + sudo adduser ffmpeg && \ + rm -rf /var/lib/apt/lists/* + +RUN useradd -ms /bin/bash $USERNAME && adduser $USERNAME sudo +RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers +USER $USERNAME +RUN mkdir -p /home/$USERNAME/video_compositor +WORKDIR /home/$USERNAME/video_compositor + +COPY --from=builder --chown=$USERNAME:$USERNAME /root/project/target/release/main_process /home/$USERNAME/video_compositor/main_process + +ENV LIVE_COMPOSITOR_WEB_RENDERER_ENABLE=0 +ENV LIVE_COMPOSITOR_WEB_RENDERER_GPU_ENABLE=0 + +ENTRYPOINT ["/home/compositor/video_compositor/main_process"]