Build Docker Images #103
Workflow file for this run
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: Build Docker Images | |
on: | |
push: | |
# We only want to build on tags--if we include branches, we build twice. | |
# branches: | |
# - main | |
# - alpha | |
# - beta | |
tags: | |
- v* | |
jobs: | |
build: | |
name: Build Docker Images | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# https://docs.docker.com/build/ci/github-actions/manage-tags-labels/ | |
# https://github.com/docker/metadata-action#tags-input | |
# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
photostructure/server | |
ghcr.io/photostructure/server | |
flavor: | | |
latest=false | |
# https://specs.opencontainers.org/image-spec/annotations/#pre-defined-annotation-keys | |
labels: | | |
org.opencontainers.image.title="PhotoStructure" | |
org.opencontainers.image.description="Your new home for all your photos and videos" | |
org.opencontainers.image.licenses="SEE LICENSE IN LICENSE.md" | |
org.opencontainers.image.url="https://photostructure.com/" | |
org.opencontainers.image.documentation="https://photostructure.com/server/photostructure-for-docker/" | |
tags: | | |
# always include the full semver (v1.2.3-alpha.1) | |
type=semver,pattern={{version}} | |
# minimal git SHA tag | |
type=sha | |
# tag every build as a :prealpha build | |
type=raw,value=prealpha | |
# unless this is a prealpha build, update the :alpha tag | |
type=raw,value=alpha,enable=${{ !contains(github.ref_name, 'prealpha') }} | |
# always update the beta tag unless it's an *alpha build, so people on :beta get the beta and stable builds: | |
type=raw,value=beta,enable=${{ !contains(github.ref_name, 'alpha') }} | |
# if it's not *alpha or beta, update :stable, :latest, and version tags. | |
type=raw,value=stable,enable=${{ !contains(github.ref_name, 'alpha') && !contains(github.ref_name, 'beta') }} | |
type=raw,value=latest,enable=${{ !contains(github.ref_name, 'alpha') && !contains(github.ref_name, 'beta') }} | |
type=semver,pattern=v{{major}},enable=${{ !contains(github.ref_name, 'alpha') && !contains(github.ref_name, 'beta') }} | |
type=semver,pattern=v{{major}}.{{minor}},enable=${{ !contains(github.ref_name, 'alpha') && !contains(github.ref_name, 'beta') }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: arm64 | |
- name: Set up Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to Docker Hub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
registry: docker.io | |
username: ${{ secrets.DOCKERHUB_USER }} | |
password: ${{ secrets.DOCKERHUB_PASS }} | |
- name: Log in to GitHub Container Registry | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |