Skip to content

Commit

Permalink
Publish docker image as part of the release process (#840)
Browse files Browse the repository at this point in the history
  • Loading branch information
noituri authored Dec 6, 2024
1 parent 7db7381 commit 2ecabeb
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 76 deletions.
62 changes: 48 additions & 14 deletions .github/workflows/package_for_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ jobs:

- uses: actions/upload-artifact@v4
with:
name: live_compositor_linux_x86_64.tar.gz
path: live_compositor_linux_x86_64.tar.gz
name: smelter_linux_x86_64.tar.gz
path: smelter_linux_x86_64.tar.gz

- uses: actions/upload-artifact@v4
with:
name: live_compositor_with_web_renderer_linux_x86_64.tar.gz
path: live_compositor_with_web_renderer_linux_x86_64.tar.gz
name: smelter_with_web_renderer_linux_x86_64.tar.gz
path: smelter_with_web_renderer_linux_x86_64.tar.gz

linux-aarch64:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -75,8 +75,8 @@ jobs:
cp *.tar.gz /artifacts
- uses: actions/upload-artifact@v4
with:
name: live_compositor_linux_aarch64.tar.gz
path: artifacts/live_compositor_linux_aarch64.tar.gz
name: smelter_linux_aarch64.tar.gz
path: artifacts/smelter_linux_aarch64.tar.gz

macos_x86_64:
runs-on: macos-12
Expand All @@ -95,13 +95,13 @@ jobs:

- uses: actions/upload-artifact@v4
with:
name: live_compositor_darwin_x86_64.tar.gz
path: live_compositor_darwin_x86_64.tar.gz
name: smelter_darwin_x86_64.tar.gz
path: smelter_darwin_x86_64.tar.gz

- uses: actions/upload-artifact@v4
with:
name: live_compositor_with_web_renderer_darwin_x86_64.tar.gz
path: live_compositor_with_web_renderer_darwin_x86_64.tar.gz
name: smelter_with_web_renderer_darwin_x86_64.tar.gz
path: smelter_with_web_renderer_darwin_x86_64.tar.gz

macos-aarch64:
runs-on: macos-14
Expand All @@ -120,10 +120,44 @@ jobs:

- uses: actions/upload-artifact@v4
with:
name: live_compositor_darwin_aarch64.tar.gz
path: live_compositor_darwin_aarch64.tar.gz
name: smelter_darwin_aarch64.tar.gz
path: smelter_darwin_aarch64.tar.gz

- uses: actions/upload-artifact@v4
with:
name: live_compositor_with_web_renderer_darwin_aarch64.tar.gz
path: live_compositor_with_web_renderer_darwin_aarch64.tar.gz
name: smelter_with_web_renderer_darwin_aarch64.tar.gz
path: smelter_with_web_renderer_darwin_aarch64.tar.gz

docker:
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout repo
uses: actions/checkout@v4

- name: 🛠️ Setup Docker
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: 🔨 Build Smelter image
run: |
docker buildx build --platform linux/amd64 -t ghcr.io/software-mansion/smelter:${{ github.sha }} -f build_tools/docker/slim.Dockerfile .
- name: 📤 Upload image
run: docker push ghcr.io/software-mansion/smelter:${{ github.sha }}

docker-with-web-renderer:
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout repo
uses: actions/checkout@v4

- name: 🛠️ Setup Docker
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: 🔨 Build Smelter with Web Renderer image
run: |
docker buildx build --platform linux/amd64 -t ghcr.io/software-mansion/smelter:${{ github.sha }}-web-renderer -f build_tools/docker/full.Dockerfile .
- name: 📤 Upload image
run: docker push ghcr.io/software-mansion/smelter:${{ github.sha }}-web-renderer
26 changes: 14 additions & 12 deletions build_tools/docker/full.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM ubuntu:noble-20240423 as builder

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

ARG USERNAME=compositor
ARG USERNAME=smelter
ARG RUST_VERSION=1.81

ENV DEBIAN_FRONTEND=noninteractive
Expand All @@ -27,17 +27,19 @@ RUN source ~/.cargo/env && cargo build --release
# Runtime image
FROM ubuntu:noble-20240423

LABEL org.opencontainers.image.source https://github.com/software-mansion/smelter

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

ARG USERNAME=compositor
ARG USERNAME=smelter

ENV DEBIAN_FRONTEND=noninteractive
ENV NVIDIA_DRIVER_CAPABILITIES=compute,graphics,utility

ENV LIVE_COMPOSITOR_MAIN_EXECUTABLE_PATH=/home/$USERNAME/live_compositor/main_process
ENV LIVE_COMPOSITOR_PROCESS_HELPER_PATH=/home/$USERNAME/live_compositor/process_helper
ENV LD_LIBRARY_PATH=/home/$USERNAME/live_compositor/lib
ENV XDG_RUNTIME_DIR=/home/$USERNAME/live_compositor/xdg_runtime
ENV LIVE_COMPOSITOR_MAIN_EXECUTABLE_PATH=/home/$USERNAME/smelter/main_process
ENV LIVE_COMPOSITOR_PROCESS_HELPER_PATH=/home/$USERNAME/smelter/process_helper
ENV LD_LIBRARY_PATH=/home/$USERNAME/smelter/lib
ENV XDG_RUNTIME_DIR=/home/$USERNAME/smelter/xdg_runtime

RUN apt-get update -y -qq && \
apt-get install -y \
Expand All @@ -48,12 +50,12 @@ RUN apt-get update -y -qq && \
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/live_compositor/xdg_runtime
WORKDIR /home/$USERNAME/live_compositor
RUN mkdir -p /home/$USERNAME/smelter/xdg_runtime
WORKDIR /home/$USERNAME/smelter

COPY --from=builder --chown=$USERNAME:$USERNAME /root/project/target/release/main_process /home/$USERNAME/live_compositor/main_process
COPY --from=builder --chown=$USERNAME:$USERNAME /root/project/target/release/process_helper /home/$USERNAME/live_compositor/process_helper
COPY --from=builder --chown=$USERNAME:$USERNAME /root/project/target/release/lib /home/$USERNAME/live_compositor/lib
COPY --from=builder --chown=$USERNAME:$USERNAME /root/project/docker/entrypoint.sh /home/$USERNAME/live_compositor/entrypoint.sh
COPY --from=builder --chown=$USERNAME:$USERNAME /root/project/target/release/main_process /home/$USERNAME/smelter/main_process
COPY --from=builder --chown=$USERNAME:$USERNAME /root/project/target/release/process_helper /home/$USERNAME/smelter/process_helper
COPY --from=builder --chown=$USERNAME:$USERNAME /root/project/target/release/lib /home/$USERNAME/smelter/lib
COPY --from=builder --chown=$USERNAME:$USERNAME /root/project/docker/entrypoint.sh /home/$USERNAME/smelter/entrypoint.sh

ENTRYPOINT ["./entrypoint.sh"]
14 changes: 8 additions & 6 deletions build_tools/docker/slim.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM ubuntu:noble-20240423 as builder

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

ARG USERNAME=compositor
ARG USERNAME=smelter
ARG RUST_VERSION=1.81

ENV DEBIAN_FRONTEND=noninteractive
Expand All @@ -26,9 +26,11 @@ RUN source ~/.cargo/env && cargo build --release --no-default-features
# Runtime image
FROM ubuntu:noble-20240423

LABEL org.opencontainers.image.source https://github.com/software-mansion/smelter

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

ARG USERNAME=compositor
ARG USERNAME=smelter

ENV DEBIAN_FRONTEND=noninteractive
ENV NVIDIA_DRIVER_CAPABILITIES=compute,graphics,utility
Expand All @@ -41,12 +43,12 @@ RUN apt-get update -y -qq && \
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/live_compositor
WORKDIR /home/$USERNAME/live_compositor
RUN mkdir -p /home/$USERNAME/smelter
WORKDIR /home/$USERNAME/smelter

COPY --from=builder --chown=$USERNAME:$USERNAME /root/project/target/release/main_process /home/$USERNAME/live_compositor/main_process
COPY --from=builder --chown=$USERNAME:$USERNAME /root/project/target/release/main_process /home/$USERNAME/smelter/main_process

ENV LIVE_COMPOSITOR_WEB_RENDERER_ENABLE=0
ENV LIVE_COMPOSITOR_WEB_RENDERER_GPU_ENABLE=0

ENTRYPOINT ["/home/compositor/live_compositor/main_process"]
ENTRYPOINT ["/home/smelter/smelter/main_process"]
44 changes: 30 additions & 14 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,42 @@ if [[ -z "$RELEASE_TAG" ]]; then
echo "RELEASE_TAG env variable is required."
exit 1
fi

if [[ -z "$COMMIT_HASH" ]]; then
echo "COMMIT_HASH env variable is required."
exit 1
fi

set -u

mkdir -p "$ROOT_DIR/release_tmp"
cd "$ROOT_DIR/release_tmp"

gh run download "$WORKFLOW_RUN_ID" -n live_compositor_linux_x86_64.tar.gz
gh run download "$WORKFLOW_RUN_ID" -n live_compositor_linux_aarch64.tar.gz
gh run download "$WORKFLOW_RUN_ID" -n live_compositor_darwin_x86_64.tar.gz
gh run download "$WORKFLOW_RUN_ID" -n live_compositor_darwin_aarch64.tar.gz
gh run download "$WORKFLOW_RUN_ID" -n live_compositor_with_web_renderer_linux_x86_64.tar.gz
gh run download "$WORKFLOW_RUN_ID" -n live_compositor_with_web_renderer_darwin_x86_64.tar.gz
gh run download "$WORKFLOW_RUN_ID" -n live_compositor_with_web_renderer_darwin_aarch64.tar.gz
gh run download "$WORKFLOW_RUN_ID" -n smelter_linux_x86_64.tar.gz
gh run download "$WORKFLOW_RUN_ID" -n smelter_linux_aarch64.tar.gz
gh run download "$WORKFLOW_RUN_ID" -n smelter_darwin_x86_64.tar.gz
gh run download "$WORKFLOW_RUN_ID" -n smelter_darwin_aarch64.tar.gz
gh run download "$WORKFLOW_RUN_ID" -n smelter_with_web_renderer_linux_x86_64.tar.gz
gh run download "$WORKFLOW_RUN_ID" -n smelter_with_web_renderer_darwin_x86_64.tar.gz
gh run download "$WORKFLOW_RUN_ID" -n smelter_with_web_renderer_darwin_aarch64.tar.gz

IMAGE_NAME="ghcr.io/software-mansion/smelter"
docker pull "${IMAGE_NAME}:${COMMIT_HASH}"
docker pull "${IMAGE_NAME}:${COMMIT_HASH}-web-renderer"

docker tag "${IMAGE_NAME}:${COMMIT_HASH}" "${IMAGE_NAME}:${RELEASE_TAG}"
docker tag "${IMAGE_NAME}:${COMMIT_HASH}-web-renderer" "${IMAGE_NAME}:${RELEASE_TAG}-web-renderer"

docker push "${IMAGE_NAME}:${RELEASE_TAG}"
docker push "${IMAGE_NAME}:${RELEASE_TAG}-web-renderer"

gh release create "$RELEASE_TAG"
gh release upload "$RELEASE_TAG" live_compositor_linux_x86_64.tar.gz
gh release upload "$RELEASE_TAG" live_compositor_linux_aarch64.tar.gz
gh release upload "$RELEASE_TAG" live_compositor_darwin_x86_64.tar.gz
gh release upload "$RELEASE_TAG" live_compositor_darwin_aarch64.tar.gz
gh release upload "$RELEASE_TAG" live_compositor_with_web_renderer_linux_x86_64.tar.gz
gh release upload "$RELEASE_TAG" live_compositor_with_web_renderer_darwin_x86_64.tar.gz
gh release upload "$RELEASE_TAG" live_compositor_with_web_renderer_darwin_aarch64.tar.gz
gh release upload "$RELEASE_TAG" smelter_linux_x86_64.tar.gz
gh release upload "$RELEASE_TAG" smelter_linux_aarch64.tar.gz
gh release upload "$RELEASE_TAG" smelter_darwin_x86_64.tar.gz
gh release upload "$RELEASE_TAG" smelter_darwin_aarch64.tar.gz
gh release upload "$RELEASE_TAG" smelter_with_web_renderer_linux_x86_64.tar.gz
gh release upload "$RELEASE_TAG" smelter_with_web_renderer_darwin_x86_64.tar.gz
gh release upload "$RELEASE_TAG" smelter_with_web_renderer_darwin_aarch64.tar.gz

rm -rf "$ROOT_DIR/release_tmp"
26 changes: 11 additions & 15 deletions src/bin/package_for_release/bundle_linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ use std::process::Command;
use crate::utils;

const X86_TARGET: &str = "x86_64-unknown-linux-gnu";
const X86_OUTPUT_FILE: &str = "live_compositor_linux_x86_64.tar.gz";
const X86_WITH_WEB_RENDERER_OUTPUT_FILE: &str =
"live_compositor_with_web_renderer_linux_x86_64.tar.gz";
const X86_OUTPUT_FILE: &str = "smelter_linux_x86_64.tar.gz";
const X86_WITH_WEB_RENDERER_OUTPUT_FILE: &str = "smelter_with_web_renderer_linux_x86_64.tar.gz";

const ARM_TARGET: &str = "aarch64-unknown-linux-gnu";
const ARM_OUTPUT_FILE: &str = "live_compositor_linux_aarch64.tar.gz";
const ARM_OUTPUT_FILE: &str = "smelter_linux_aarch64.tar.gz";

pub fn bundle_linux_app() -> Result<()> {
tracing_subscriber::fmt().init();
Expand All @@ -33,15 +32,15 @@ fn bundle_app(
enable_web_rendering: bool,
) -> Result<()> {
if enable_web_rendering {
info!("Bundling compositor with web rendering");
info!("Bundling smelter with web rendering");
} else {
info!("Bundling compositor without web rendering");
info!("Bundling smelter without web rendering");
}

let root_dir_str = env!("CARGO_MANIFEST_DIR");
let root_dir: PathBuf = root_dir_str.into();
let release_dir = root_dir.join(format!("target/{target_name}/release"));
let tmp_dir = root_dir.join("live_compositor");
let tmp_dir = root_dir.join("smelter");
utils::setup_bundle_dir(&tmp_dir)?;

info!("Build main_process binary.");
Expand All @@ -57,19 +56,19 @@ fn bundle_app(
info!("Copy main_process binary.");
fs::copy(
release_dir.join("main_process"),
tmp_dir.join("live_compositor_main"),
tmp_dir.join("smelter_main"),
)?;

info!("Copy process_helper binary.");
fs::copy(
release_dir.join("process_helper"),
tmp_dir.join("live_compositor_process_helper"),
tmp_dir.join("smelter_process_helper"),
)?;

info!("Copy wrapper script.");
fs::copy(
root_dir.join("src/bin/package_for_release/linux_runtime_wrapper.sh"),
tmp_dir.join("live_compositor"),
tmp_dir.join("smelter"),
)?;

info!(
Expand All @@ -81,15 +80,12 @@ fn bundle_app(
dir::copy(release_dir.join("lib"), tmp_dir, &CopyOptions::default())?;
} else {
info!("Copy main_process binary.");
fs::copy(
release_dir.join("main_process"),
tmp_dir.join("live_compositor"),
)?;
fs::copy(release_dir.join("main_process"), tmp_dir.join("smelter"))?;
}

info!("Create tar.gz archive.");
let exit_code = Command::new("tar")
.args(["-C", root_dir_str, "-czvf", output_name, "live_compositor"])
.args(["-C", root_dir_str, "-czvf", output_name, "smelter"])
.spawn()?
.wait()?
.code();
Expand Down
25 changes: 10 additions & 15 deletions src/bin/package_for_release/bundle_macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ use log::info;
use crate::utils;

const ARM_MAC_TARGET: &str = "aarch64-apple-darwin";
const ARM_OUTPUT_FILE: &str = "live_compositor_darwin_aarch64.tar.gz";
const ARM_WITH_WEB_RENDERER_OUTPUT_FILE: &str =
"live_compositor_with_web_renderer_darwin_aarch64.tar.gz";
const ARM_OUTPUT_FILE: &str = "smelter_darwin_aarch64.tar.gz";
const ARM_WITH_WEB_RENDERER_OUTPUT_FILE: &str = "smelter_with_web_renderer_darwin_aarch64.tar.gz";

const INTEL_MAC_TARGET: &str = "x86_64-apple-darwin";
const INTEL_OUTPUT_FILE: &str = "live_compositor_darwin_x86_64.tar.gz";
const INTEL_WITH_WEB_RENDERER_OUTPUT_FILE: &str =
"live_compositor_with_web_renderer_darwin_x86_64.tar.gz";
const INTEL_OUTPUT_FILE: &str = "smelter_darwin_x86_64.tar.gz";
const INTEL_WITH_WEB_RENDERER_OUTPUT_FILE: &str = "smelter_with_web_renderer_darwin_x86_64.tar.gz";

pub fn bundle_macos_app() -> Result<()> {
tracing_subscriber::fmt().init();
Expand All @@ -35,15 +33,15 @@ pub fn bundle_macos_app() -> Result<()> {

fn bundle_app(target: &'static str, output_name: &str, enable_web_rendering: bool) -> Result<()> {
if enable_web_rendering {
info!("Bundling compositor with web rendering");
info!("Bundling smelter with web rendering");
} else {
info!("Bundling compositor without web rendering");
info!("Bundling smelter without web rendering");
}

let root_dir_str = env!("CARGO_MANIFEST_DIR");
let root_dir: PathBuf = root_dir_str.into();
let build_dir = root_dir.join(format!("target/{target}/release"));
let tmp_dir = root_dir.join("live_compositor");
let tmp_dir = root_dir.join("smelter");
utils::setup_bundle_dir(&tmp_dir)?;

info!("Build main_process binary.");
Expand All @@ -56,17 +54,14 @@ fn bundle_app(target: &'static str, output_name: &str, enable_web_rendering: boo

info!("Build process_helper binary.");
utils::cargo_build("process_helper", target, false)?;
cef::bundle_app(&build_dir, &tmp_dir.join("live_compositor.app"))?;
cef::bundle_app(&build_dir, &tmp_dir.join("smelter.app"))?;
}

fs::copy(
build_dir.join("main_process"),
tmp_dir.join("live_compositor"),
)?;
fs::copy(build_dir.join("main_process"), tmp_dir.join("smelter"))?;

info!("Create tar.gz archive.");
let exit_code = Command::new("tar")
.args(["-C", root_dir_str, "-czvf", output_name, "live_compositor"])
.args(["-C", root_dir_str, "-czvf", output_name, "smelter"])
.spawn()?
.wait()?
.code();
Expand Down

0 comments on commit 2ecabeb

Please sign in to comment.