Skip to content

Commit 939edbd

Browse files
committed
Refactor Docker build/publish workflow to GHCR, drop usdzconvert
Moved Docker image publishing from Docker Hub to GitHub Container Registry. The new GitHub Actions workflow now uses `docker buildx` for streamlined multi-architecture (amd64, arm64) builds and manifest list creation. The `usdzconvert` toolchain has been removed from the Docker image, refocusing its purpose solely on compiling Apple's AR schemas into OpenUSD. Updated `Dockerfile`, local build/utility scripts, and `README.md` to reflect these changes and improve maintainability.
1 parent c7cf4cb commit 939edbd

22 files changed

Lines changed: 296 additions & 6674 deletions

.github/workflows/publish.yml

Lines changed: 163 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,181 @@
11
name: docker publish
2+
23
on:
34
push:
45
tags:
56
- '*'
7+
workflow_dispatch:
8+
inputs:
9+
usd_version:
10+
description: 'OpenUSD version to build (e.g. 26.05). The ghcr.io/plattar/python-usd:version-<usd_version> base image must already exist.'
11+
required: true
12+
default: '26.05'
13+
type: string
14+
image_tag:
15+
description: 'Image tag to publish (defaults to the OpenUSD version above).'
16+
required: false
17+
default: ''
18+
type: string
19+
tag_latest:
20+
description: 'Also publish the image as :latest.'
21+
required: false
22+
default: false
23+
type: boolean
24+
25+
env:
26+
REGISTRY: ghcr.io
27+
628
jobs:
7-
build-amd64:
29+
setup:
830
runs-on: ubuntu-latest
9-
timeout-minutes: 360
31+
outputs:
32+
usd_version: ${{ steps.derive.outputs.usd_version }}
33+
image_tag: ${{ steps.derive.outputs.image_tag }}
34+
image_name: ${{ steps.derive.outputs.image_name }}
35+
tag_latest: ${{ steps.derive.outputs.tag_latest }}
1036
steps:
11-
- name: checkout code
12-
uses: actions/checkout@v3
13-
- name: setup qemu
14-
uses: docker/setup-qemu-action@v2
15-
- name: setup buildx
16-
id: buildx
17-
uses: docker/setup-buildx-action@v2
18-
- name: print available platforms
19-
run: echo ${{ steps.buildx.outputs.platforms }}
20-
- name: set version from tag
21-
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
22-
- name: print version number
23-
run: echo ${{ env.RELEASE_VERSION }}
24-
- name: login to dockerhub
25-
uses: docker/login-action@v2
26-
with:
27-
username: ${{ secrets.DOCKER_UPLOAD_USERNAME }}
28-
password: ${{ secrets.DOCKER_UPLOAD_TOKEN }}
29-
- name: build & upload
37+
- name: derive build parameters
38+
id: derive
3039
run: |
31-
docker buildx build \
32-
--push \
33-
--tag plattar/python-usd-ar:version-${{ env.RELEASE_VERSION }}-amd64 \
34-
--platform linux/amd64 \
35-
--file Dockerfile .
36-
build-arm64:
37-
runs-on: ubuntu-latest
40+
set -euo pipefail
41+
42+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
43+
usd_version="${{ inputs.usd_version }}"
44+
image_tag="${{ inputs.image_tag }}"
45+
tag_latest="${{ inputs.tag_latest }}"
46+
else
47+
ref="${GITHUB_REF#refs/tags/}"
48+
usd_version="${ref#v}"
49+
image_tag="$ref"
50+
tag_latest="true"
51+
fi
52+
53+
if [[ -z "$image_tag" ]]; then
54+
image_tag="$usd_version"
55+
fi
56+
57+
image_name="$(echo "${{ github.repository_owner }}/python-usd-ar" | tr '[:upper:]' '[:lower:]')"
58+
59+
echo "usd_version=$usd_version" >> "$GITHUB_OUTPUT"
60+
echo "image_tag=$image_tag" >> "$GITHUB_OUTPUT"
61+
echo "image_name=$image_name" >> "$GITHUB_OUTPUT"
62+
echo "tag_latest=$tag_latest" >> "$GITHUB_OUTPUT"
63+
64+
echo "Building OpenUSD v${usd_version} -> ${{ env.REGISTRY }}/${image_name}:${image_tag} (latest=${tag_latest})"
65+
66+
build:
67+
needs: setup
68+
strategy:
69+
fail-fast: false
70+
matrix:
71+
include:
72+
- platform: linux/amd64
73+
runner: ubuntu-latest
74+
- platform: linux/arm64
75+
runner: ubuntu-24.04-arm
76+
runs-on: ${{ matrix.runner }}
3877
timeout-minutes: 360
78+
permissions:
79+
contents: read
80+
packages: write
3981
steps:
82+
- name: prepare platform pair
83+
run: |
84+
platform="${{ matrix.platform }}"
85+
echo "PLATFORM_PAIR=${platform//\//-}" >> "$GITHUB_ENV"
86+
4087
- name: checkout code
41-
uses: actions/checkout@v3
42-
- name: setup qemu
43-
uses: docker/setup-qemu-action@v2
88+
uses: actions/checkout@v4
89+
4490
- name: setup buildx
45-
id: buildx
46-
uses: docker/setup-buildx-action@v2
47-
- name: print available platforms
48-
run: echo ${{ steps.buildx.outputs.platforms }}
49-
- name: set version from tag
50-
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
51-
- name: print version number
52-
run: echo ${{ env.RELEASE_VERSION }}
53-
- name: login to dockerhub
54-
uses: docker/login-action@v2
91+
uses: docker/setup-buildx-action@v3
92+
93+
- name: login to GHCR
94+
uses: docker/login-action@v3
5595
with:
56-
username: ${{ secrets.DOCKER_UPLOAD_USERNAME }}
57-
password: ${{ secrets.DOCKER_UPLOAD_TOKEN }}
58-
- name: build & upload
96+
registry: ${{ env.REGISTRY }}
97+
username: ${{ github.actor }}
98+
password: ${{ secrets.GITHUB_TOKEN }}
99+
100+
- name: build and push by digest
101+
id: build
102+
uses: docker/build-push-action@v6
103+
with:
104+
context: .
105+
file: Dockerfile
106+
platforms: ${{ matrix.platform }}
107+
build-args: |
108+
USD_VERSION=${{ needs.setup.outputs.usd_version }}
109+
labels: |
110+
org.opencontainers.image.title=python-usd-ar
111+
org.opencontainers.image.version=${{ needs.setup.outputs.image_tag }}
112+
org.opencontainers.image.revision=${{ github.sha }}
113+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
114+
outputs: type=image,name=${{ env.REGISTRY }}/${{ needs.setup.outputs.image_name }},push-by-digest=true,name-canonical=true,push=true
115+
116+
- name: export digest
59117
run: |
60-
docker buildx build \
61-
--push \
62-
--tag plattar/python-usd-ar:version-${{ env.RELEASE_VERSION }}-arm64 \
63-
--platform linux/arm64 \
64-
--file Dockerfile .
65-
build-manifest:
118+
mkdir -p /tmp/digests
119+
digest="${{ steps.build.outputs.digest }}"
120+
touch "/tmp/digests/${digest#sha256:}"
121+
122+
- name: upload digest
123+
uses: actions/upload-artifact@v4
124+
with:
125+
name: digests-${{ env.PLATFORM_PAIR }}
126+
path: /tmp/digests/*
127+
if-no-files-found: error
128+
retention-days: 1
129+
130+
merge:
131+
needs: [setup, build]
66132
runs-on: ubuntu-latest
67-
timeout-minutes: 360
68-
needs: [build-amd64, build-arm64]
133+
permissions:
134+
contents: read
135+
packages: write
69136
steps:
70-
- name: checkout code
71-
uses: actions/checkout@v3
72-
- name: set version from tag
73-
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
74-
- name: print version number
75-
run: echo ${{ env.RELEASE_VERSION }}
76-
- name: login to dockerhub
77-
uses: docker/login-action@v2
137+
- name: download digests
138+
uses: actions/download-artifact@v4
139+
with:
140+
path: /tmp/digests
141+
pattern: digests-*
142+
merge-multiple: true
143+
144+
- name: setup buildx
145+
uses: docker/setup-buildx-action@v3
146+
147+
- name: login to GHCR
148+
uses: docker/login-action@v3
78149
with:
79-
username: ${{ secrets.DOCKER_UPLOAD_USERNAME }}
80-
password: ${{ secrets.DOCKER_UPLOAD_TOKEN }}
81-
- name: create manifest
82-
run: docker manifest create plattar/python-usd-ar:version-${{ env.RELEASE_VERSION }} plattar/python-usd-ar:version-${{ env.RELEASE_VERSION }}-amd64 plattar/python-usd-ar:version-${{ env.RELEASE_VERSION }}-arm64
83-
- name: upload manifest
84-
run: docker manifest push plattar/python-usd-ar:version-${{ env.RELEASE_VERSION }}
150+
registry: ${{ env.REGISTRY }}
151+
username: ${{ github.actor }}
152+
password: ${{ secrets.GITHUB_TOKEN }}
153+
154+
- name: assemble tag args
155+
id: tags
156+
run: |
157+
set -euo pipefail
158+
image="${{ env.REGISTRY }}/${{ needs.setup.outputs.image_name }}"
159+
tags=("version-${{ needs.setup.outputs.image_tag }}" "${{ needs.setup.outputs.image_tag }}")
160+
if [[ "${{ needs.setup.outputs.tag_latest }}" == "true" ]]; then
161+
tags+=("latest")
162+
fi
163+
args=""
164+
for t in "${tags[@]}"; do
165+
args+=" -t ${image}:${t}"
166+
done
167+
echo "args=${args}" >> "$GITHUB_OUTPUT"
168+
169+
- name: create multi-arch manifest
170+
working-directory: /tmp/digests
171+
run: |
172+
set -euo pipefail
173+
image="${{ env.REGISTRY }}/${{ needs.setup.outputs.image_name }}"
174+
# shellcheck disable=SC2046
175+
docker buildx imagetools create ${{ steps.tags.outputs.args }} \
176+
$(printf "${image}@sha256:%s " *)
177+
178+
- name: inspect
179+
run: |
180+
docker buildx imagetools inspect \
181+
${{ env.REGISTRY }}/${{ needs.setup.outputs.image_name }}:${{ needs.setup.outputs.image_tag }}

Dockerfile

Lines changed: 71 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,77 @@
1-
# Create a base from a pre-compiled version of USD tools
2-
# More info @ https://github.com/Plattar/python-usd
3-
# Unlike the python-usd container, python-usd-ar also contains the Schema
4-
# Definitions for ARKit and is useful for generating USDZ files with various
5-
# AR Features.
6-
# NOTE: As of 30/06/2022 this respository also builds and sets up
7-
# usdzconvert tools
8-
# For more info on usdconvert, visit https://developer.apple.com/augmented-reality/tools/
9-
FROM plattar/python-usd:version-22.05b-slim-bullseye
1+
# syntax=docker/dockerfile:1.7
102

11-
LABEL MAINTAINER PLATTAR(www.plattar.com)
3+
# Python USD AR — adds Apple's "Preliminary_" AR schemas on top of python-usd.
4+
#
5+
# These schemas (Preliminary_AnchoringAPI, Preliminary_Behavior, Preliminary_Trigger,
6+
# Preliminary_Action, Preliminary_ReferenceImage, Preliminary_Text) come from Apple's
7+
# USDZ Schemas for AR addendum and are still not upstreamed into OpenUSD, so they
8+
# have to be code-generated and compiled into libusd at build time.
9+
#
10+
# See: https://developer.apple.com/documentation/arkit/usdz_schemas_for_ar
11+
ARG USD_VERSION=26.05
12+
FROM ghcr.io/plattar/python-usd:version-${USD_VERSION}
1213

13-
ENV USD_SCHEMA_FOLDER="usd_schemas"
14-
ENV USDZCONVERT_FOLDER="usdzconvert"
15-
ENV USDZCONVERT_VERSION="0.66"
14+
LABEL org.opencontainers.image.source="https://github.com/Plattar/python-usd-ar"
15+
LABEL org.opencontainers.image.description="Pixar OpenUSD with Apple's Preliminary_* AR schemas compiled in"
16+
LABEL org.opencontainers.image.licenses="Apache-2.0"
17+
LABEL org.opencontainers.image.vendor="Plattar"
1618

17-
WORKDIR /usr/src/app
19+
# USD_VERSION, USD_BUILD_PATH, USD_BIN_PATH, USD_LIB_PATH, USD_PLUGIN_PATH,
20+
# PATH, LD_LIBRARY_PATH and PYTHONPATH are inherited from the python-usd base.
21+
22+
ENV USD_SCHEMA_FOLDER=usd_schemas
1823

19-
# Update the environment path for USDZ Convert Tools
20-
ENV USDZCONVERT_BIN_PATH="/usr/src/app/xrutils/${USDZCONVERT_FOLDER}"
21-
ENV PATH="${PATH}:${USDZCONVERT_BIN_PATH}"
24+
WORKDIR /usr/src/app
2225

23-
# copy source folders into container
24-
COPY /${USD_SCHEMA_FOLDER} /usr/src/app/${USD_SCHEMA_FOLDER}
25-
COPY /${USDZCONVERT_FOLDER} ${USDZCONVERT_BIN_PATH}
26+
COPY ${USD_SCHEMA_FOLDER}/ /usr/src/app/${USD_SCHEMA_FOLDER}/
2627

27-
RUN apt-get update && apt-get install -y --no-install-recommends \
28-
git \
29-
build-essential \
30-
cmake \
31-
nasm \
32-
libxrandr-dev \
33-
libxcursor-dev \
34-
libxinerama-dev \
35-
libxi-dev && \
36-
rm -rf /var/lib/apt/lists/* && \
37-
# Clone the USD Repository
38-
git clone --branch "v${USD_VERSION}" --depth 1 https://github.com/PixarAnimationStudios/USD.git usdsrc && \
39-
# Copy the AR Schema Components into the examples folder
40-
cp -a /usr/src/app/${USD_SCHEMA_FOLDER}/usdInteractive/ usdsrc/pxr/usd/ && \
41-
# Use usdGenSchema to Generate all CPP source files that will be built
42-
cd usdsrc/pxr/usd/usdInteractive && usdGenSchema schema.usda . && cd /usr/src/app && \
43-
# Add the directories into the CMakeLists.txt so everything gets built
44-
echo "add_subdirectory(usdInteractive)" >> usdsrc/pxr/usd/CMakeLists.txt && \
45-
# Remove the old USD installation
46-
rm -rf ${USD_BUILD_PATH} && \
47-
# build a new version with our new schemas
48-
python3 usdsrc/build_scripts/build_usd.py --no-examples --no-tutorials --no-imaging --no-usdview --no-draco --no-docs --no-tests ${USD_BUILD_PATH} && \
49-
# remove source code as we don't need it anymore
50-
rm -rf usdsrc && \
51-
rm -rf ${USD_SCHEMA_FOLDER} && \
52-
# remove build files we no longer need to save space
53-
rm -rf ${USD_BUILD_PATH}/build && \
54-
rm -rf ${USD_BUILD_PATH}/cmake && \
55-
rm -rf ${USD_BUILD_PATH}/pxrConfig.cmake && \
56-
rm -rf ${USD_BUILD_PATH}/share && \
57-
rm -rf ${USD_BUILD_PATH}/src && \
58-
# remove packages we no longer need/require
59-
# this keeps the container as small as possible
60-
# if others need them, they can install when extending
61-
apt-get purge -y git \
62-
build-essential \
63-
cmake \
64-
nasm \
65-
libxrandr-dev \
66-
libxcursor-dev \
67-
libxinerama-dev \
68-
libxi-dev && \
69-
apt autoremove -y && \
70-
apt-get autoclean -y
28+
RUN set -eux; \
29+
apt-get update; \
30+
apt-get install -y --no-install-recommends \
31+
git \
32+
ca-certificates \
33+
build-essential \
34+
cmake \
35+
nasm \
36+
libxrandr-dev \
37+
libxcursor-dev \
38+
libxinerama-dev \
39+
libxi-dev; \
40+
rm -rf /var/lib/apt/lists/*; \
41+
git clone --branch "v${USD_VERSION}" --depth 1 https://github.com/PixarAnimationStudios/OpenUSD.git usdsrc; \
42+
# Drop the Apple schema package into the OpenUSD source tree
43+
cp -a /usr/src/app/${USD_SCHEMA_FOLDER}/usdInteractive/ usdsrc/pxr/usd/; \
44+
# Use the inherited usdGenSchema (from the python-usd base) to turn schema.usda
45+
# into C++ source. Done before re-running build_usd.py so the new sources get picked up.
46+
(cd usdsrc/pxr/usd/usdInteractive && usdGenSchema schema.usda .); \
47+
echo "add_subdirectory(usdInteractive)" >> usdsrc/pxr/usd/CMakeLists.txt; \
48+
# Rebuild USD into the same prefix. boost/tbb/oneTBB are already present and
49+
# get skipped by build_usd.py; only USD itself is recompiled (with the new schema).
50+
python3 usdsrc/build_scripts/build_usd.py \
51+
--no-examples \
52+
--no-tutorials \
53+
--no-imaging \
54+
--no-usdview \
55+
--no-draco \
56+
--no-materialx \
57+
${USD_BUILD_PATH}; \
58+
rm -rf usdsrc; \
59+
rm -rf /usr/src/app/${USD_SCHEMA_FOLDER}; \
60+
rm -rf \
61+
${USD_BUILD_PATH}/build \
62+
${USD_BUILD_PATH}/cmake \
63+
${USD_BUILD_PATH}/pxrConfig.cmake \
64+
${USD_BUILD_PATH}/share \
65+
${USD_BUILD_PATH}/src; \
66+
apt-get purge -y \
67+
git \
68+
build-essential \
69+
cmake \
70+
nasm \
71+
libxrandr-dev \
72+
libxcursor-dev \
73+
libxinerama-dev \
74+
libxi-dev; \
75+
apt-get autoremove -y; \
76+
apt-get autoclean -y; \
77+
rm -rf /var/lib/apt/lists/*

0 commit comments

Comments
 (0)