Files
FreshRSS/.github/workflows/docker-publish.yml
Inverle 6908d998d4 Fix .dockerignore being ignored during build in CI (#9001)
For example:

f201061345/.dockerignore (L6)

`/docs/` is included in `.dockerignore`, but currently if you check `docker exec freshrss ls -la`, you'll notice `/docs/` is being listed despite that.

This is because we are using git context for the build instead of path context, see: https://github.com/docker/build-push-action#git-context

Compare the runs https://github.com/Inverle/FreshRSS/actions/runs/28884689769/job/85681744466 and https://github.com/Inverle/FreshRSS/actions/runs/28885427454/job/85684280287 by CTRL+F'ing for `.dockerignore` in the `Build and push Docker images` step.
In the second run, a line `#5 [internal] load .dockerignore` is printed, but not in the first run without `context: .`

Additionally, it can be confirmed this fix is working by checking the `ghcr.io/inverle/freshrss:docker-testing-alpine` image for the `/docs/` directory.
2026-07-08 20:46:35 +02:00

97 lines
3.2 KiB
YAML

name: Publish Docker images
on:
push:
branches:
- edge
release:
types: [published]
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
build-container-image:
name: Build Docker image ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: Debian
file: Docker/Dockerfile
flavor: |
latest=auto
tags: |
type=edge,onlatest=false
type=semver,pattern={{version}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/0.') }}
# type=semver,pattern={{major}}.{{minor}}
- name: Alpine
file: Docker/Dockerfile-Alpine
flavor: |
latest=false
tags: |
type=raw,value=alpine,enable=${{ github.ref == 'refs/heads/latest' || startsWith(github.ref, 'refs/tags/') }}
type=edge,suffix=-alpine,onlatest=false
type=semver,pattern={{version}}-alpine
type=semver,pattern={{major}}-alpine,enable=${{ !startsWith(github.ref, 'refs/tags/0.') }}
# type=semver,pattern={{major}}.{{minor}}-alpine
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Checkout
uses: actions/checkout@v7
- name: Get FreshRSS version
run: |
FRESHRSS_VERSION=$(sed -n "s/^const FRESHRSS_VERSION = '\(.*\)'.*$/\1/p" constants.php)
echo "$FRESHRSS_VERSION"
echo "FRESHRSS_VERSION=$FRESHRSS_VERSION" >> $GITHUB_ENV
- name: Add metadata to Docker images
id: meta
uses: docker/metadata-action@v6
with:
flavor: ${{ matrix.flavor }}
images: |
docker.io/freshrss/freshrss
ghcr.io/${{ github.repository }}
tags: ${{ matrix.tags }}
labels: |
org.opencontainers.image.url=https://freshrss.org/
org.opencontainers.image.version=${{ env.FRESHRSS_VERSION }}
- name: Login to Docker Hub
if: github.repository_owner == 'FreshRSS'
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: github.repository_owner == 'FreshRSS'
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker images
uses: docker/build-push-action@v7
with:
context: . # Switching from git context to path context, needed for .dockerignore to be applied. See: https://github.com/docker/build-push-action#git-context
file: ${{ matrix.file }}
platforms: linux/amd64,linux/arm/v7,linux/arm64
build-args: |
FRESHRSS_VERSION=${{ env.FRESHRSS_VERSION }}
SOURCE_COMMIT=${{ github.sha }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ (github.ref == 'refs/heads/latest' || github.ref == 'refs/heads/edge' || startsWith(github.ref, 'refs/tags/')) && github.repository_owner == 'FreshRSS' }}