multiarch!
This commit is contained in:
@@ -1,24 +0,0 @@
|
|||||||
name: Gitea Actions Demo
|
|
||||||
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
|
||||||
on: [push]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
Build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Build the project
|
|
||||||
run: |
|
|
||||||
./build.sh
|
|
||||||
- name: Login to Gitea
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: gitea.jde.nz
|
|
||||||
username: DoesntMatter
|
|
||||||
password: ${{ secrets.DOCKER_PUSH_TOKEN }}
|
|
||||||
- name: Publish
|
|
||||||
run: |
|
|
||||||
./publish.sh
|
|
||||||
|
|
||||||
|
|
82
.gitea/workflows/buildpublish.yaml
Normal file
82
.gitea/workflows/buildpublish.yaml
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
name: Build-Publish-Multi-Arch
|
||||||
|
run-name: Build and publish multi-architecture Docker images
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
platform:
|
||||||
|
- linux/amd64
|
||||||
|
- linux/arm64
|
||||||
|
runs-on: ${{ matrix.platform }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Login to Gitea
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: gitea.jde.nz
|
||||||
|
username: DoesntMatter
|
||||||
|
password: ${{ secrets.DOCKER_PUSH_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build Images
|
||||||
|
run: |
|
||||||
|
./build.sh
|
||||||
|
|
||||||
|
- name: Publish as Architecture-Specific
|
||||||
|
run: |
|
||||||
|
# Only publish on main branch
|
||||||
|
if [ "$GITHUB_REF" = "refs/heads/main" ]; then
|
||||||
|
DOCKER_PUSH_TOKEN=${{ secrets.DOCKER_PUSH_TOKEN }} \
|
||||||
|
./publish.sh
|
||||||
|
fi
|
||||||
|
|
||||||
|
create-manifest:
|
||||||
|
needs: [build]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Login to Gitea
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: gitea.jde.nz
|
||||||
|
username: DoesntMatter
|
||||||
|
password: ${{ secrets.DOCKER_PUSH_TOKEN }}
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y jq
|
||||||
|
|
||||||
|
- name: Create and push manifest lists
|
||||||
|
run: |
|
||||||
|
# Only create manifest on main branch
|
||||||
|
if [ "$GITHUB_REF" = "refs/heads/main" ]; then
|
||||||
|
# Get list of all Dockerfile.* files to determine image names
|
||||||
|
for dockerfile in Dockerfile.*; do
|
||||||
|
image_name="${dockerfile//Dockerfile./}"
|
||||||
|
|
||||||
|
echo "Creating manifest for ${image_name}..."
|
||||||
|
|
||||||
|
# Create the manifest list using the architecture-specific digests
|
||||||
|
docker manifest create gitea.jde.nz/public/${image_name}:latest \
|
||||||
|
--amend gitea.jde.nz/public/${image_name}:latest-x86_64 \
|
||||||
|
--amend gitea.jde.nz/public/${image_name}:latest-aarch64
|
||||||
|
|
||||||
|
# Push the manifest list
|
||||||
|
docker manifest push gitea.jde.nz/public/${image_name}:latest
|
||||||
|
|
||||||
|
echo "Manifest list for ${image_name} created and pushed successfully"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "All manifest lists created and pushed successfully"
|
||||||
|
fi
|
@@ -24,13 +24,11 @@ RUN apt-get update && apt-get install -y \
|
|||||||
python3.11-venv \
|
python3.11-venv \
|
||||||
# FFmpeg with hardware acceleration support
|
# FFmpeg with hardware acceleration support
|
||||||
ffmpeg \
|
ffmpeg \
|
||||||
# Intel QuickSync / VAAPI dependencies
|
# VAAPI dependencies (generic, works on both x86_64 and arm64)
|
||||||
intel-media-va-driver-non-free \
|
|
||||||
vainfo \
|
vainfo \
|
||||||
libva-drm2 \
|
libva-drm2 \
|
||||||
libva-dev \
|
libva-dev \
|
||||||
libva2 \
|
libva2 \
|
||||||
i965-va-driver \
|
|
||||||
# OpenGL/Graphics libraries
|
# OpenGL/Graphics libraries
|
||||||
libgl1 \
|
libgl1 \
|
||||||
libglib2.0-0 \
|
libglib2.0-0 \
|
||||||
@@ -71,6 +69,14 @@ RUN apt-get update && apt-get install -y \
|
|||||||
gfortran \
|
gfortran \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Install architecture-specific Intel drivers (only on x86_64)
|
||||||
|
RUN if [ "$(dpkg --print-architecture)" = "amd64" ]; then \
|
||||||
|
apt-get update && apt-get install -y \
|
||||||
|
intel-media-va-driver-non-free \
|
||||||
|
i965-va-driver \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*; \
|
||||||
|
fi
|
||||||
|
|
||||||
# Set Python 3.11 as default
|
# Set Python 3.11 as default
|
||||||
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1 && \
|
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1 && \
|
||||||
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 && \
|
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 && \
|
||||||
@@ -94,13 +100,12 @@ RUN pip install --no-cache-dir \
|
|||||||
requests
|
requests
|
||||||
|
|
||||||
# Install PyTorch CPU version (can be overridden in derived images for CUDA)
|
# Install PyTorch CPU version (can be overridden in derived images for CUDA)
|
||||||
|
# Note: PyTorch provides different wheels for different architectures
|
||||||
RUN pip install --no-cache-dir \
|
RUN pip install --no-cache-dir \
|
||||||
torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
|
torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
|
||||||
|
|
||||||
# Set environment variables for hardware acceleration
|
# Set environment variables for hardware acceleration
|
||||||
# Intel QuickSync / VAAPI
|
# VAAPI driver configuration (paths will be set at runtime via entrypoint)
|
||||||
ENV LIBVA_DRIVER_NAME=iHD
|
|
||||||
ENV LIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri
|
|
||||||
|
|
||||||
# Python environment
|
# Python environment
|
||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
@@ -124,6 +129,15 @@ RUN useradd -m -s /bin/bash -u 1000 appuser && \
|
|||||||
RUN mkdir -p /app /data /models && \
|
RUN mkdir -p /app /data /models && \
|
||||||
chown -R appuser:appuser /app /data /models
|
chown -R appuser:appuser /app /data /models
|
||||||
|
|
||||||
|
# Create entrypoint script to set architecture-specific environment variables
|
||||||
|
RUN echo '#!/bin/bash\n\
|
||||||
|
export LIBVA_DRIVERS_PATH=/usr/lib/$(uname -m)-linux-gnu/dri\n\
|
||||||
|
if [ "$(uname -m)" = "x86_64" ]; then\n\
|
||||||
|
export LIBVA_DRIVER_NAME=iHD\n\
|
||||||
|
fi\n\
|
||||||
|
exec "$@"' > /entrypoint.sh && \
|
||||||
|
chmod +x /entrypoint.sh
|
||||||
|
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@@ -134,5 +148,8 @@ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|||||||
# Default to non-root user (can be overridden in derived images)
|
# Default to non-root user (can be overridden in derived images)
|
||||||
USER appuser
|
USER appuser
|
||||||
|
|
||||||
|
# Set entrypoint
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
|
||||||
# Default command - can be overridden in derived images
|
# Default command - can be overridden in derived images
|
||||||
CMD ["/bin/bash"]
|
CMD ["/bin/bash"]
|
34
publish.sh
34
publish.sh
@@ -3,22 +3,34 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
ARCH=$(uname -m)
|
||||||
|
|
||||||
# get date/time in local timezone, format YYYY.MMDD.HHMMSS
|
echo "Publishing generic-docker-images to gitea.jde.nz/public/<image_name>:latest-${ARCH}"
|
||||||
DATETIME=$(date +%Y.%m%d.%H%M%S)
|
|
||||||
|
|
||||||
"${SCRIPTDIR}/build.sh"
|
function die() {
|
||||||
|
echo "error: $1"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
# iterate through the docker files in format Dockerfile.IMAGE_NAME
|
# Build all images
|
||||||
|
"${SCRIPTDIR}/build.sh" || die "Build failed"
|
||||||
|
|
||||||
|
# Iterate through the docker files in format Dockerfile.IMAGE_NAME
|
||||||
for dockerfile in Dockerfile.*
|
for dockerfile in Dockerfile.*
|
||||||
do
|
do
|
||||||
# get the image name from the dockerfile
|
# Get the image name from the dockerfile
|
||||||
image_name="${dockerfile//Dockerfile./}"
|
image_name="${dockerfile//Dockerfile./}"
|
||||||
# tag the image with the latest tag
|
|
||||||
docker tag "$image_name:latest" "gitea.jde.nz/public/$image_name:latest"
|
# Create and push the arch-specific docker image
|
||||||
docker tag "$image_name:latest" "gitea.jde.nz/public/$image_name:$DATETIME"
|
IMAGE_NAME="gitea.jde.nz/public/${image_name}:latest-${ARCH}"
|
||||||
# push the image to the local docker registry
|
|
||||||
docker push -a "gitea.jde.nz/public/$image_name"
|
# Tag the locally built image with arch-specific tag
|
||||||
|
docker tag "${image_name}:latest" "${IMAGE_NAME}"
|
||||||
|
|
||||||
|
# Push the arch-specific image
|
||||||
|
docker push "${IMAGE_NAME}"
|
||||||
|
|
||||||
|
echo "Pushed ${IMAGE_NAME}"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo "All architecture-specific images pushed successfully"
|
Reference in New Issue
Block a user