2023-11-29 05:07:47 +02:00
|
|
|
name: Docker
|
2023-01-21 17:38:27 +02:00
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
push:
|
|
|
|
branches: [main]
|
|
|
|
pull_request:
|
|
|
|
branches: [main]
|
|
|
|
release:
|
|
|
|
types: [published]
|
|
|
|
|
2023-02-19 18:44:53 +02:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2023-04-12 22:52:01 +02:00
|
|
|
permissions:
|
|
|
|
packages: write
|
|
|
|
|
2023-01-21 17:38:27 +02:00
|
|
|
jobs:
|
|
|
|
build_and_push:
|
2023-11-29 05:07:47 +02:00
|
|
|
name: Build and Push
|
2023-01-21 17:38:27 +02:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
# Prevent a failure in one image from stopping the other builds
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
include:
|
2024-01-22 01:22:39 +02:00
|
|
|
- image: immich-machine-learning
|
|
|
|
context: machine-learning
|
|
|
|
file: machine-learning/Dockerfile
|
|
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
device: cpu
|
2023-11-09 15:12:05 +02:00
|
|
|
|
2024-01-22 01:22:39 +02:00
|
|
|
- image: immich-machine-learning
|
|
|
|
context: machine-learning
|
|
|
|
file: machine-learning/Dockerfile
|
|
|
|
platforms: linux/amd64
|
|
|
|
device: cuda
|
|
|
|
suffix: -cuda
|
|
|
|
|
|
|
|
- image: immich-machine-learning
|
|
|
|
context: machine-learning
|
|
|
|
file: machine-learning/Dockerfile
|
|
|
|
platforms: linux/amd64
|
|
|
|
device: openvino
|
|
|
|
suffix: -openvino
|
2024-02-06 13:17:15 +02:00
|
|
|
|
2024-01-22 01:22:39 +02:00
|
|
|
- image: immich-machine-learning
|
|
|
|
context: machine-learning
|
|
|
|
file: machine-learning/Dockerfile
|
|
|
|
platforms: linux/arm64
|
|
|
|
device: armnn
|
|
|
|
suffix: -armnn
|
|
|
|
|
|
|
|
- image: immich-server
|
|
|
|
context: .
|
|
|
|
file: server/Dockerfile
|
|
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
device: cpu
|
2024-02-06 13:17:15 +02:00
|
|
|
|
2023-08-03 06:27:38 +02:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2023-09-06 03:50:22 +02:00
|
|
|
uses: actions/checkout@v4
|
2023-08-03 06:27:38 +02:00
|
|
|
|
|
|
|
- name: Set up QEMU
|
2023-09-12 14:22:37 +02:00
|
|
|
uses: docker/setup-qemu-action@v3.0.0
|
2023-08-03 06:27:38 +02:00
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
2024-04-08 18:21:49 +02:00
|
|
|
uses: docker/setup-buildx-action@v3.3.0
|
2023-08-03 06:27:38 +02:00
|
|
|
|
|
|
|
- name: Login to Docker Hub
|
|
|
|
# Only push to Docker Hub when making a release
|
|
|
|
if: ${{ github.event_name == 'release' }}
|
2023-09-12 14:16:26 +02:00
|
|
|
uses: docker/login-action@v3
|
2023-08-03 06:27:38 +02:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Login to GitHub Container Registry
|
2023-09-12 14:16:26 +02:00
|
|
|
uses: docker/login-action@v3
|
2023-01-21 17:38:27 +02:00
|
|
|
# Skip when PR from a fork
|
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.repository_owner }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Generate docker image tags
|
|
|
|
id: metadata
|
2023-09-12 14:15:16 +02:00
|
|
|
uses: docker/metadata-action@v5
|
2023-01-21 17:38:27 +02:00
|
|
|
with:
|
|
|
|
flavor: |
|
|
|
|
# Disable latest tag
|
|
|
|
latest=false
|
|
|
|
images: |
|
|
|
|
name=ghcr.io/${{ github.repository_owner }}/${{matrix.image}}
|
|
|
|
name=altran1502/${{matrix.image}},enable=${{ github.event_name == 'release' }}
|
|
|
|
tags: |
|
|
|
|
# Tag with branch name
|
2024-01-22 01:22:39 +02:00
|
|
|
type=ref,event=branch,suffix=${{ matrix.suffix }}
|
2023-01-21 17:38:27 +02:00
|
|
|
# Tag with pr-number
|
2024-01-22 01:22:39 +02:00
|
|
|
type=ref,event=pr,suffix=${{ matrix.suffix }}
|
2023-01-21 17:38:27 +02:00
|
|
|
# Tag with git tag on release
|
2024-01-22 01:22:39 +02:00
|
|
|
type=ref,event=tag,suffix=${{ matrix.suffix }}
|
|
|
|
type=raw,value=release,enable=${{ github.event_name == 'release' }},suffix=${{ matrix.suffix }}
|
2023-01-21 17:38:27 +02:00
|
|
|
|
2023-01-26 21:22:46 +02:00
|
|
|
- name: Determine build cache output
|
|
|
|
id: cache-target
|
|
|
|
run: |
|
|
|
|
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
|
|
|
# Essentially just ignore the cache output (PR can't write to registry cache)
|
|
|
|
echo "cache-to=type=local,dest=/tmp/discard,ignore-error=true" >> $GITHUB_OUTPUT
|
|
|
|
else
|
|
|
|
echo "cache-to=type=registry,mode=max,ref=ghcr.io/${{ github.repository_owner }}/immich-build-cache:${{ matrix.image }}" >> $GITHUB_OUTPUT
|
|
|
|
fi
|
|
|
|
|
2023-01-21 17:38:27 +02:00
|
|
|
- name: Build and push image
|
2024-06-22 20:10:47 +02:00
|
|
|
uses: docker/build-push-action@v6.1.0
|
2023-01-21 17:38:27 +02:00
|
|
|
with:
|
|
|
|
context: ${{ matrix.context }}
|
2023-11-18 06:13:36 +02:00
|
|
|
file: ${{ matrix.file }}
|
2023-02-18 21:15:23 +02:00
|
|
|
platforms: ${{ matrix.platforms }}
|
2023-01-21 17:38:27 +02:00
|
|
|
# Skip pushing when PR from a fork
|
|
|
|
push: ${{ !github.event.pull_request.head.repo.fork }}
|
2023-01-26 21:22:46 +02:00
|
|
|
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/immich-build-cache:${{matrix.image}}
|
|
|
|
cache-to: ${{ steps.cache-target.outputs.cache-to }}
|
|
|
|
tags: ${{ steps.metadata.outputs.tags }}
|
2023-02-03 22:22:00 +02:00
|
|
|
labels: ${{ steps.metadata.outputs.labels }}
|
2024-06-26 14:25:09 +02:00
|
|
|
build-args: |
|
|
|
|
DEVICE=${{ matrix.device }}
|
|
|
|
BUILD_ID=${{ github.run_id }}
|
|
|
|
BUILD_IMAGE=${{ github.event_name == 'release' && github.ref_name || steps.metadata.outputs.tags }}
|
|
|
|
BUILD_SOURCE_REF=${{ github.ref_name }}
|
|
|
|
BUILD_SOURCE_COMMIT=${{ github.sha }}
|