Skip to content

Docker Build

Docker Build #30

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:
- {latest: "true", selkies: "1.6.1"}
steps:
-
name: Free Space
run: |
df -h
rm -rf /usr/share/dotnet
rm -rf /opt/ghc
rm -rf /usr/local/share/boost
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: |
target="${HOME}/work/${{ env.REPO_NAME }}/${{ env.REPO_NAME }}/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.selkies }} || ${{ matrix.build.selkies }} == "latest" ]]; then
SELKIES_VERSION="$(curl -fsSL "https://api.github.com/repos/selkies-project/selkies-gstreamer/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g')"
else
SELKIES_VERSION=${{ matrix.build.selkies }}
fi
[[ -n $SELKIES_VERSION ]] || { echo "Error: SELKIES_VERSION is empty. Exiting script." >&2; exit 1; }
echo "SELKIES_VERSION=${SELKIES_VERSION}" >> ${GITHUB_ENV}
base_tag="v2-cpu-${{ env.UBUNTU_VERSION }}"
if [[ ${{ matrix.build.latest }} == "true" ]]; then
echo "Marking latest"
# GHCR.io Tags
TAGS="${img_path_ghcr}:${base_tag}, ${base_tag}-v${SELKIES_VERSION}, ${img_path_ghcr}:latest-cpu"
# Docker.io Tags
TAGS="${TAGS}, ${img_path_dhub}:${SELKIES_VERSION}-ubuntu-${{ env.UBUNTU_VERSION }}, ${img_path_dhub}:latest"
else
TAGS="${img_path_ghcr}:${base_tag}-v${SELKIES_VERSION}, ${img_path_dhub}:v${SELKIES_VERSION}-ubuntu-${{ env.UBUNTU_VERSION }}"
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/base-image:v2-cpu-${{ env.UBUNTU_VERSION }}
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:
- {latest: "true", selkies: "1.6.1", cuda: "12.1.1-cudnn8-runtime"}
- {latest: "false", selkies: "1.6.1", cuda: "12.1.1-cudnn8-devel"}
steps:
-
name: Free Space
run: |
df -h
rm -rf /usr/share/dotnet
rm -rf /opt/ghc
rm -rf /usr/local/share/boost
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: |
target="${HOME}/work/${{ env.REPO_NAME }}/${{ env.REPO_NAME }}/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.selkies }} || ${{ matrix.build.selkies }} == "latest" ]]; then
SELKIES_VERSION="$(curl -fsSL "https://api.github.com/repos/selkies-project/selkies-gstreamer/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g')"
else
SELKIES_VERSION=${{ matrix.build.selkies }}
fi
[[ -n $SELKIES_VERSION ]] || { echo "Error: SELKIES_VERSION is empty. Exiting script." >&2; exit 1; }
echo "SELKIES_VERSION=${SELKIES_VERSION}" >> ${GITHUB_ENV}
base_tag="v2-cuda-${{ matrix.build.cuda }}-${{ env.UBUNTU_VERSION }}"
if [[ ${{ matrix.build.latest }} == "true" ]]; then
echo "Marking latest"
# GHCR.io Tags
TAGS="${img_path_ghcr}:${base_tag}, ${img_path_ghcr}:${base_tag}-v${SELKIES_VERSION}, ${img_path_ghcr}:latest, ${img_path_ghcr}:latest-cuda"
# Docker.io Tags
TAGS="${TAGS}, ${img_path_dhub}:v${SELKIES_VERSION}-${{ matrix.build.cuda }}, ${img_path_dhub}:latest"
else
TAGS="${img_path_ghcr}:${base_tag}-v${SELKIES_VERSION}, ${img_path_dhub}:v${SELKIES_VERSION}-${{ matrix.build.cuda }}"
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/base-image:v2-cuda-${{ matrix.build.cuda }}-${{ env.UBUNTU_VERSION }}
push: true
provenance: false
tags: ${{ env.TAGS }}
amd-base:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
build:
- {latest: "true", selkies: "1.6.1", rocm: "6.0-runtime"}
- {latest: "false", selkies: "1.6.1", rocm: "6.0-devel"}
steps:
-
name: Free Space
run: |
df -h
rm -rf /usr/share/dotnet
rm -rf /opt/ghc
rm -rf /usr/local/share/boost
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: |
target="${HOME}/work/${{ env.REPO_NAME }}/${{ env.REPO_NAME }}/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.selkies }} || ${{ matrix.build.selkies }} == "latest" ]]; then
SELKIES_VERSION="$(curl -fsSL "https://api.github.com/repos/selkies-project/selkies-gstreamer/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g')"
else
SELKIES_VERSION=${{ matrix.build.selkies }}
fi
[[ -n $SELKIES_VERSION ]] || { echo "Error: SELKIES_VERSION is empty. Exiting script." >&2; exit 1; }
echo "SELKIES_VERSION=${SELKIES_VERSION}" >> ${GITHUB_ENV}
base_tag="v2-cuda-${{ matrix.build.rocm }}-${{ env.UBUNTU_VERSION }}"
if [[ ${{ matrix.build.latest }} == "true" ]]; then
echo "Marking latest"
# GHCR.io Tags
TAGS="${img_path_ghcr}:${base_tag}, ${img_path_ghcr}:${base_tag}-v${SELKIES_VERSION}, ${img_path_ghcr}:latest-rocm"
# Docker.io Tags
TAGS="${TAGS}, ${img_path_dhub}:v${SELKIES_VERSION}-${{ matrix.build.rocm }}, ${img_path_dhub}:latest"
else
TAGS="${img_path_ghcr}:${base_tag}-v${SELKIES_VERSION}, ${img_path_dhub}:v${SELKIES_VERSION}-${{ matrix.build.rocm }}"
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/base-image:v2-rocm-${{ matrix.build.rocm }}-${{ env.UBUNTU_VERSION }}
push: true
provenance: false
tags: ${{ env.TAGS }}