Skip to content

Docker Build

Docker Build #8

Workflow file for this run

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 release tag finds latest from GitHub tags
- {latest: "false", fooocus: "d7439b2", python: "3.10", pytorch: "2.5.1"}
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: |
REPO=${GITHUB_REPOSITORY,,}
echo "REPO_NAMESPACE=${REPO%%/*}" >> ${GITHUB_ENV}
echo "REPO_NAME=${REPO#*/}" >> ${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 DockerHub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Set tags
run: |
img_path_ghcr="ghcr.io/${{ env.REPO_NAMESPACE }}/${{ env.REPO_NAME }}"
img_path_dhub="${{ vars.DOCKERHUB_USER }}/${{ env.REPO_NAME }}-cpu"
if [[ -z '${{ matrix.build.fooocus }}' ]]; then
FOOOCUS_BUILD_REF="$(curl -s https://api.github.com/repos/lllyasviel/Fooocus/tags | jq -r '.[0].name')"
else
FOOOCUS_BUILD_REF="${{ matrix.build.fooocus }}"
fi
[ -z "$FOOOCUS_BUILD_REF" ] && { echo "Error: FOOOCUS_BUILD_REF is empty. Exiting script." >&2; exit 1; }
echo "FOOOCUS_BUILD_REF=${FOOOCUS_BUILD_REF}" >> ${GITHUB_ENV}
if [[ -z '${{ matrix.build.fooocus_api }}' ]]; then
FOOOCUS_API_BUILD_REF="$(curl -s https://api.github.com/repos/mrhan1993/Fooocus-API/tags | jq -r '.[0].name')"
else
FOOOCUS_API_BUILD_REF="${{ matrix.build.fooocus_api }}"
fi
[ -z "$FOOOCUS_API_BUILD_REF" ] && { echo "Error: FOOOCUS_API_BUILD_REF is empty. Exiting script." >&2; exit 1; }
echo "FOOOCUS_API_BUILD_REF=${FOOOCUS_API_BUILD_REF}" >> ${GITHUB_ENV}
base_tag="v2-cpu-${{ env.UBUNTU_VERSION }}"
if [[ ${{ matrix.build.latest }} == "true" ]]; then
echo "Marking latest"
TAGS="${img_path_ghcr}:${base_tag}-${FOOOCUS_BUILD_REF}, ${img_path_ghcr}:${base_tag}, ${img_path_ghcr}:latest-cpu"
else
TAGS="${img_path_ghcr}:${base_tag}-${FOOOCUS_BUILD_REF}"
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 }}-v2-cpu-${{ env.UBUNTU_VERSION }}
PYTHON_VERSION=${{ matrix.build.python }}
PYTORCH_VERSION=${{ matrix.build.pytorch }}
FOOOCUS_BUILD_REF=${{ env.FOOOCUS_BUILD_REF }}
FOOOCUS_API_BUILD_REF=${{ env.FOOOCUS_API_BUILD_REF }}
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 release tag finds latest from GitHub tags
- {latest: "false", fooocus: "d7439b2", python: "3.10", pytorch: "2.5.1", cuda: "12.1.1-base"}
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: |
REPO=${GITHUB_REPOSITORY,,}
echo "REPO_NAMESPACE=${REPO%%/*}" >> ${GITHUB_ENV}
echo "REPO_NAME=${REPO#*/}" >> ${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 DockerHub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Set tags
run: |
img_path_ghcr="ghcr.io/${{ env.REPO_NAMESPACE }}/${{ env.REPO_NAME }}"
img_path_dhub="${{ vars.DOCKERHUB_USER }}/${{ env.REPO_NAME }}-cuda"
if [[ -z '${{ matrix.build.fooocus }}' ]]; then
FOOOCUS_BUILD_REF="$(curl -s https://api.github.com/repos/lllyasviel/Fooocus/tags | jq -r '.[0].name')"
else
FOOOCUS_BUILD_REF="${{ matrix.build.fooocus }}"
fi
[ -z "$FOOOCUS_BUILD_REF" ] && { echo "Error: FOOOCUS_BUILD_REF is empty. Exiting script." >&2; exit 1; }
echo "FOOOCUS_BUILD_REF=${FOOOCUS_BUILD_REF}" >> ${GITHUB_ENV}
if [[ -z '${{ matrix.build.fooocus_api }}' ]]; then
FOOOCUS_API_BUILD_REF="$(curl -s https://api.github.com/repos/mrhan1993/Fooocus-API/tags | jq -r '.[0].name')"
else
FOOOCUS_API_BUILD_REF="${{ matrix.build.fooocus_api }}"
fi
[ -z "$FOOOCUS_API_BUILD_REF" ] && { echo "Error: FOOOCUS_API_BUILD_REF is empty. Exiting script." >&2; exit 1; }
echo "FOOOCUS_API_BUILD_REF=${FOOOCUS_API_BUILD_REF}" >> ${GITHUB_ENV}
base_tag="v2-cuda-${{ matrix.build.cuda }}-${{ env.UBUNTU_VERSION }}"
if [[ ${{ matrix.build.latest }} == "true" ]]; then
echo "Marking latest"
TAGS="${img_path_ghcr}:${base_tag}-${FOOOCUS_BUILD_REF}, ${img_path_ghcr}:${base_tag}, ${img_path_ghcr}:latest, ${img_path_ghcr}:latest-cuda"
TAGS="${TAGS}, ${img_path_dhub}:${FOOOCUS_BUILD_REF}, ${img_path_dhub}:latest"
else
TAGS="${img_path_ghcr}:${base_tag}-${FOOOCUS_BUILD_REF}, ${img_path_dhub}:${FOOOCUS_BUILD_REF}"
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 }}-v2-cuda-${{ matrix.build.cuda }}-${{ env.UBUNTU_VERSION }}
PYTHON_VERSION=${{ matrix.build.python }}
PYTORCH_VERSION=${{ matrix.build.pytorch }}
FOOOCUS_BUILD_REF=${{ env.FOOOCUS_BUILD_REF }}
FOOOCUS_API_BUILD_REF=${{ env.FOOOCUS_API_BUILD_REF }}
push: true
provenance: false
tags: ${{ env.TAGS }}
amd-base:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
build:
- {latest: "false", fooocus: "d7439b2", python: "3.10", pytorch: "2.3.0", rocm: "6.0-core"}
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: |
REPO=${GITHUB_REPOSITORY,,}
echo "REPO_NAMESPACE=${REPO%%/*}" >> ${GITHUB_ENV}
echo "REPO_NAME=${REPO#*/}" >> ${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 DockerHub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Set tags
run: |
img_path_ghcr="ghcr.io/${{ env.REPO_NAMESPACE }}/${{ env.REPO_NAME }}"
img_path_dhub="${{ vars.DOCKERHUB_USER }}/${{ env.REPO_NAME }}-rocm"
if [[ -z '${{ matrix.build.fooocus }}' ]]; then
FOOOCUS_BUILD_REF="$(curl -s https://api.github.com/repos/lllyasviel/Fooocus/tags | jq -r '.[0].name')"
else
FOOOCUS_BUILD_REF="${{ matrix.build.fooocus }}"
fi
[ -z "$FOOOCUS_BUILD_REF" ] && { echo "Error: FOOOCUS_BUILD_REF is empty. Exiting script." >&2; exit 1; }
echo "FOOOCUS_BUILD_REF=${FOOOCUS_BUILD_REF}" >> ${GITHUB_ENV}
if [[ -z '${{ matrix.build.fooocus_api }}' ]]; then
FOOOCUS_API_BUILD_REF="$(curl -s https://api.github.com/repos/mrhan1993/Fooocus-API/tags | jq -r '.[0].name')"
else
FOOOCUS_API_BUILD_REF="${{ matrix.build.fooocus_api }}"
fi
[ -z "$FOOOCUS_API_BUILD_REF" ] && { echo "Error: FOOOCUS_API_BUILD_REF is empty. Exiting script." >&2; exit 1; }
echo "FOOOCUS_API_BUILD_REF=${FOOOCUS_API_BUILD_REF}" >> ${GITHUB_ENV}
base_tag="v2-rocm-${{ matrix.build.rocm }}-${{ env.UBUNTU_VERSION }}"
if [[ ${{ matrix.build.latest }} == "true" ]]; then
echo "Marking latest"
TAGS="${img_path_ghcr}:${base_tag}-${FOOOCUS_BUILD_REF}, ${img_path_ghcr}:${base_tag}, ${img_path_ghcr}:latest-rocm"
else
TAGS="${img_path_ghcr}:${base_tag}-${FOOOCUS_BUILD_REF}"
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 }}-v2-rocm-${{ matrix.build.rocm }}-${{ env.UBUNTU_VERSION }}
PYTHON_VERSION=${{ matrix.build.python }}
PYTORCH_VERSION=${{ matrix.build.pytorch }}
FOOOCUS_BUILD_REF=${{ env.FOOOCUS_BUILD_REF }}
FOOOCUS_API_BUILD_REF=${{ env.FOOOCUS_API_BUILD_REF }}
push: true
provenance: false
tags: ${{ env.TAGS }}