Docker Build #55
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Build | |
on: | |
workflow_dispatch: | |
#push: | |
# branches: [ "main" ] | |
env: | |
UBUNTU_VERSION: 22.04 | |
BUILDX_NO_DEFAULT_ATTESTATIONS: 1 | |
jobs: | |
cpu-base: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
build: | |
# Undeclared SHA tags with latest commit from master branch | |
- {latest: "true", sha: "719fb2c", python: "3.10", pytorch: "2.2.2"} | |
steps: | |
- | |
name: Free Space | |
run: | | |
df -h | |
sudo rm -rf /usr/share/dotnet | |
sudo rm -rf /opt/ghc | |
sudo rm -rf /usr/local/.ghcup | |
sudo rm -rf /usr/local/share/boost | |
sudo rm -rf /usr/local/lib/android | |
sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
df -h | |
- | |
name: Env Setter | |
run: | | |
echo "PACKAGE_NAME=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV} | |
- | |
name: Checkout | |
uses: actions/checkout@v3 | |
- | |
name: Permissions fixes | |
run: | | |
reponame="$(basename ${GITHUB_REPOSITORY})" | |
target="${HOME}/work/${reponame}/${reponame}/build/COPY*" | |
chmod -R ug+rwX ${target} | |
- | |
name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Set tags | |
run: | | |
img_path="ghcr.io/${{ env.PACKAGE_NAME }}" | |
if [[ -z '${{ matrix.build.sha }}' ]]; then | |
COMFYUI_SHA="$(curl -fsSL "https://api.github.com/repos/comfyanonymous/ComfyUI/commits/master" | jq -r '.sha[0:7]')" | |
else | |
COMFYUI_SHA="${{ matrix.build.sha }}" | |
fi | |
[ -z "$COMFYUI_SHA" ] && { echo "Error: COMFYUI_SHA is empty. Exiting script." >&2; exit 1; } | |
echo "COMFYUI_SHA=${COMFYUI_SHA}" >> ${GITHUB_ENV} | |
base_tag="pytorch-${{ matrix.build.pytorch }}-py${{ matrix.build.python }}-cpu-${{ env.UBUNTU_VERSION }}" | |
sha_tag="${base_tag}-${COMFYUI_SHA}" | |
TAGS="${img_path}:${sha_tag}" | |
if [[ ${{ matrix.build.latest }} == "true" ]]; then | |
echo "Marking latest" | |
TAGS+=", ${img_path}:latest-cpu, ${img_path}:latest-cpu-jupyter" | |
fi | |
echo "TAGS=${TAGS}" >> ${GITHUB_ENV} | |
- | |
name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: build | |
build-args: | | |
IMAGE_BASE=ghcr.io/ai-dock/python:${{ matrix.build.python }}-cpu-${{ env.UBUNTU_VERSION }} | |
PYTHON_VERSION=${{ matrix.build.python }} | |
PYTORCH_VERSION=${{ matrix.build.pytorch }} | |
COMFYUI_SHA=${{ env.COMFYUI_SHA }} | |
push: true | |
# Avoids unknown/unknown architecture and extra metadata | |
provenance: false | |
tags: ${{ env.TAGS }} | |
nvidia-base: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
build: | |
# Undeclared SHA tags with latest commit from master branch | |
- {latest: "true", sha: "719fb2c", python: "3.10", pytorch: "2.2.2", cuda: "11.8.0-runtime"} | |
- {latest: "false", sha: "719fb2c", python: "3.10", pytorch: "2.2.2", cuda: "12.1.0-runtime"} | |
steps: | |
- | |
name: Free Space | |
run: | | |
df -h | |
sudo rm -rf /usr/share/dotnet | |
sudo rm -rf /opt/ghc | |
sudo rm -rf /usr/local/.ghcup | |
sudo rm -rf /usr/local/share/boost | |
sudo rm -rf /usr/local/lib/android | |
sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
df -h | |
- | |
name: Env Setter | |
run: | | |
echo "PACKAGE_NAME=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV} | |
- | |
name: Checkout | |
uses: actions/checkout@v3 | |
- | |
name: Permissions fixes | |
run: | | |
reponame="$(basename ${GITHUB_REPOSITORY})" | |
target="${HOME}/work/${reponame}/${reponame}/build/COPY*" | |
chmod -R ug+rwX ${target} | |
- | |
name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Set tags | |
run: | | |
img_path="ghcr.io/${{ env.PACKAGE_NAME }}" | |
if [[ -z '${{ matrix.build.sha }}' ]]; then | |
COMFYUI_SHA="$(curl -fsSL "https://api.github.com/repos/comfyanonymous/ComfyUI/commits/master" | jq -r '.sha[0:7]')" | |
else | |
COMFYUI_SHA="${{ matrix.build.sha }}" | |
fi | |
[ -z "$COMFYUI_SHA" ] && { echo "Error: COMFYUI_SHA is empty. Exiting script." >&2; exit 1; } | |
echo "COMFYUI_SHA=${COMFYUI_SHA}" >> ${GITHUB_ENV} | |
base_tag="pytorch-${{ matrix.build.pytorch }}-py${{ matrix.build.python }}-cuda-${{ matrix.build.cuda }}-${{ env.UBUNTU_VERSION }}" | |
sha_tag="${base_tag}-${COMFYUI_SHA}" | |
TAGS="${img_path}:${sha_tag}" | |
if [[ ${{ matrix.build.latest }} == "true" ]]; then | |
echo "Marking latest" | |
TAGS+=", ${img_path}:latest, ${img_path}:latest-jupyter, ${img_path}:latest-cuda, ${img_path}:latest-cuda-jupyter" | |
fi | |
echo "TAGS=${TAGS}" >> ${GITHUB_ENV} | |
- | |
name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: build | |
build-args: | | |
IMAGE_BASE=ghcr.io/ai-dock/python:${{ matrix.build.python }}-cuda-${{ matrix.build.cuda }}-${{ env.UBUNTU_VERSION }} | |
PYTHON_VERSION=${{ matrix.build.python }} | |
PYTORCH_VERSION=${{ matrix.build.pytorch }} | |
COMFYUI_SHA=${{ env.COMFYUI_SHA }} | |
push: true | |
provenance: false | |
tags: ${{ env.TAGS }} | |
amd-base: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
build: | |
# Undeclared SHA tags with latest commit from master branch | |
- {latest: "true", sha: "719fb2c", python: "3.10", pytorch: "2.2.2", rocm: "5.7-runtime"} | |
steps: | |
- | |
name: Free Space | |
run: | | |
df -h | |
sudo rm -rf /usr/share/dotnet | |
sudo rm -rf /opt/ghc | |
sudo rm -rf /usr/local/.ghcup | |
sudo rm -rf /usr/local/share/boost | |
sudo rm -rf /usr/local/lib/android | |
sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
df -h | |
- | |
name: Env Setter | |
run: | | |
echo "PACKAGE_NAME=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV} | |
- | |
name: Checkout | |
uses: actions/checkout@v3 | |
- | |
name: Permissions fixes | |
run: | | |
reponame="$(basename ${GITHUB_REPOSITORY})" | |
target="${HOME}/work/${reponame}/${reponame}/build/COPY*" | |
chmod -R ug+rwX ${target} | |
- | |
name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Set tags | |
run: | | |
img_path="ghcr.io/${{ env.PACKAGE_NAME }}" | |
if [[ -z '${{ matrix.build.sha }}' ]]; then | |
COMFYUI_SHA="$(curl -fsSL "https://api.github.com/repos/comfyanonymous/ComfyUI/commits/master" | jq -r '.sha[0:7]')" | |
else | |
COMFYUI_SHA="${{ matrix.build.sha }}" | |
fi | |
[ -z "$COMFYUI_SHA" ] && { echo "Error: COMFYUI_SHA is empty. Exiting script." >&2; exit 1; } | |
echo "COMFYUI_SHA=${COMFYUI_SHA}" >> ${GITHUB_ENV} | |
base_tag="pytorch-${{ matrix.build.pytorch }}-py${{ matrix.build.python }}-rocm-${{ matrix.build.rocm }}-${{ env.UBUNTU_VERSION }}" | |
sha_tag="${base_tag}-${COMFYUI_SHA}" | |
TAGS="${img_path}:${sha_tag}" | |
if [[ ${{ matrix.build.latest }} == "true" ]]; then | |
echo "Marking latest" | |
TAGS+=", ${img_path}:latest-rocm, ${img_path}:latest-rocm-jupyter" | |
fi | |
echo "TAGS=${TAGS}" >> ${GITHUB_ENV} | |
- | |
name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: build | |
build-args: | | |
IMAGE_BASE=ghcr.io/ai-dock/python:${{ matrix.build.python }}-rocm-${{ matrix.build.rocm }}-${{ env.UBUNTU_VERSION }} | |
PYTHON_VERSION=${{ matrix.build.python }} | |
PYTORCH_VERSION=${{ matrix.build.pytorch }} | |
COMFYUI_SHA=${{ env.COMFYUI_SHA }} | |
push: true | |
provenance: false | |
tags: ${{ env.TAGS }} |