Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add multi arch docker build #5808

Merged
merged 36 commits into from Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
28eec20
Add multi arch container build
b-reich Nov 2, 2023
7bd3a15
using label from github action
b-reich Nov 3, 2023
e3e72b4
dont remove static labels and split docker readme in seperate action
b-reich Nov 3, 2023
1e2f4d4
pin 3rd party action to a commit
b-reich Nov 3, 2023
f29c107
enable pushing to dockerhub
b-reich Nov 3, 2023
51497c9
Update .github/workflows/build-images.yml
b-reich Nov 3, 2023
47e4520
remove not needed checkout
b-reich Nov 3, 2023
9bae9fe
set github token permissions
b-reich Nov 3, 2023
0e4a51d
Update .github/workflows/push-dockerhub-readme.yml
Alkarex Nov 3, 2023
0ef449d
update docker readme to match new tags
b-reich Nov 3, 2023
50f36c1
Apply suggestions from code review
Alkarex Nov 4, 2023
735be30
Merge branch 'edge' into edge
Alkarex Nov 4, 2023
3ea33af
fix suffix for alpine image
b-reich Nov 4, 2023
8255ac7
fix suffix for alpine image
b-reich Nov 4, 2023
97ff089
push images only at upstream repo
b-reich Nov 4, 2023
de09a2a
push images only at upstream repo
b-reich Nov 4, 2023
1bf588a
push images only at upstream repo
b-reich Nov 4, 2023
73f9417
tag latest-alpine as alpine
b-reich Nov 4, 2023
8a09f8e
tag latest-alpine as alpine
b-reich Nov 4, 2023
b65b047
remove no needed falvor
b-reich Nov 4, 2023
b5aede3
keep falvor for build
b-reich Nov 4, 2023
4de930b
Clean more things
Alkarex Nov 5, 2023
0b041d0
Rename action
Alkarex Nov 5, 2023
fdc0807
Rename readme action
Alkarex Nov 5, 2023
d583cf8
Use default name for dockerhub-description
Alkarex Nov 5, 2023
239b8e7
Experiment with build-args
Alkarex Nov 5, 2023
6929640
Debug
Alkarex Nov 5, 2023
34411c9
Add checkout back
Alkarex Nov 5, 2023
f5155d7
Revert back to metadata-action
Alkarex Nov 5, 2023
78c57ed
Remove quotes in version
Alkarex Nov 5, 2023
052d1ac
Try to fix variables
Alkarex Nov 5, 2023
bdeb0a0
Experiment with automatic label values again
Alkarex Nov 5, 2023
5da2c90
Delete last Docker Hub hooks
Alkarex Nov 5, 2023
3d110b8
Use only git SHA for org.opencontainers.image.revision
Alkarex Nov 5, 2023
97af192
Comment out semver for now
Alkarex Nov 5, 2023
fd69343
Enable major semver
Alkarex Nov 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
94 changes: 94 additions & 0 deletions .github/workflows/docker-publish.yml
@@ -0,0 +1,94 @@
name: Publish Docker images

on:
push:
branches:
- edge
release:
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
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/0.') }}
- 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}}.{{minor}}-alpine
type=semver,pattern={{major}}-alpine,enable=${{ !startsWith(github.ref, 'refs/tags/0.') }}
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Checkout
uses: actions/checkout@v4

- 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@v5
with:
flavor: ${{ matrix.flavor }}
images: |
docker.io/freshrss/freshrss
# ghcr.io/${{ github.repository }}
tags: ${{ matrix.tags }}
labels: |
org.opencontainers.image.revision=${{ github.ref_name }}.${{ github.sha }}
org.opencontainers.image.version=${{ env.FRESHRSS_VERSION }}
Copy link
Contributor Author

@b-reich b-reich Nov 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is already handle by the org.opencontainers.image.revision label which is the commit hash
dont know if there is benefit to know which branch is build from, when you have the commit

also thinks the container version label is fine with sometthing like 1.22.2 or 1.22.2-alpineits specify the container version not the version of the application itself

Copy link
Member

@Alkarex Alkarex Nov 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there is benefit to know which branch is build from

This is mostly because this is what we already have, and I find it a bit easier to read with something like 1.22.1.cc2878aed855463efe36cf6fb96d001dbb75612e. But I would not be much against leaving it to only the git SHA, if this is what is most standard.

Edit: indeed, according to https://specs.opencontainers.org/image-spec/annotations/#pre-defined-annotation-keys : org.opencontainers.image.revision Source control revision identifier for the packaged software.
I will edit accordingly

also thinks the container version label is fine with sometthing like 1.22.2 or 1.22.2-alpineits specify the container version not the version of the application itself

I would also be happy with 1.22.2-alpine, but that does not work for e.g. edge builds

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched back to default revision 3d110b8


- name: Login to Docker Hub
if: github.repository_owner == 'FreshRSS'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# - name: Login to GitHub Container Registry
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.repository_owner }}
# password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker images
uses: docker/build-push-action@v5
with:
file: ${{ matrix.file }}
platforms: linux/arm/v7,linux/arm64,linux/amd64
build-args: |
FRESHRSS_VERSION=${{ env.FRESHRSS_VERSION }}
SOURCE_BRANCH=${{ github.ref_name }}
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' }}
24 changes: 24 additions & 0 deletions .github/workflows/dockerhub-description.yml
@@ -0,0 +1,24 @@
name: Update Docker Hub description

on:
push:
paths:
- Docker/README.md
branches:
- edge
workflow_dispatch:

jobs:
dockerhub-description:
if: github.repository_owner == 'FreshRSS'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Update repo description
uses: peter-evans/dockerhub-description@dc67fad7001ef9e8e3c124cb7a64e16d0a63d864
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: freshrss/freshrss
readme-filepath: Docker/README.md
81 changes: 0 additions & 81 deletions Docker/Dockerfile-QEMU-ARM

This file was deleted.

32 changes: 7 additions & 25 deletions Docker/README.md
Expand Up @@ -66,13 +66,16 @@ The [tags](https://hub.docker.com/r/freshrss/freshrss/tags) correspond to FreshR

* `:latest` (default) is the [latest stable release](https://github.com/FreshRSS/FreshRSS/releases/latest)
* `:edge` is the rolling release, same than our [git `edge` branch](https://github.com/FreshRSS/FreshRSS/tree/edge)
* `:x.y.z` are [specific FreshRSS releases](https://github.com/FreshRSS/FreshRSS/releases)
* `:arm` or `:*-arm` are the ARM `arm32v7` versions (e.g., for Raspberry Pi).
* `:x.y.z` tags correspond to [specific FreshRSS releases](https://github.com/FreshRSS/FreshRSS/releases), allowing you to target a precise version for deployment
* `:x.y` tags are tied to a specific major version and minor version number. For example, `:1.23` will automatically receive updates for any `1.23.x` releases, but will not update to `1.24.x`
* `:x` tags track the latest release within a major version series. For instance, `:1` will update to include any `1.x` releases, but will exclude versions beyond `2.x`
* `*-alpine` use Linux Alpine as base-image instead of Debian
* Our Docker images are designed with multi-architecture support, accommodating a variety of Linux platforms including `linux/arm/v7`, `linux/arm64`, and `linux/amd64`.
* For other platforms, see the [custom build section](#build-custom-docker-image)

### Linux: Debian vs. Alpine

Our default image is based on [Debian](https://www.debian.org/). We offer an alternative based on [Alpine](https://alpinelinux.org/) (with the `:alpine` or `*-alpine` tag suffix).
Alkarex marked this conversation as resolved.
Show resolved Hide resolved
Our default image is based on [Debian](https://www.debian.org/). We offer an alternative based on [Alpine](https://alpinelinux.org/) (with the `*-alpine` tag suffix).
In [our tests](https://github.com/FreshRSS/FreshRSS/pull/2205) (2019), Alpine was slower,
while Alpine is smaller on disk (and much faster to build),
and with newer packages in general (Apache, PHP).
Expand Down Expand Up @@ -108,7 +111,7 @@ docker rm freshrss_old
## Build custom Docker image

Building your own Docker image is especially relevant for platforms not available on our Docker Hub,
which is currently limited to `x64` (Intel, AMD) and `arm32v7`.
which is currently limited to `x64` (Intel, AMD), `arm32v7`, `arm64`.

> ℹ️ If you try to run an image for the wrong platform, you might get an error message like *exec format error*.

Expand Down Expand Up @@ -395,27 +398,6 @@ docker-compose down --remove-orphans --volumes

> ℹ️ You can combine it with `-f docker-compose-db.yml` to spin a PostgreSQL database.

### Docker Compose and ARM64

If you’re working or want to host on an ARM64 system (such as Apple Silicon (M1/M2)) you’ll need to use the `arm` tag in your `docker-compose.yml` file:
```yaml
image: freshrss/freshrss:arm
```

If you then get this error message when running `docker compose up`:

> The requested image’s platform (linux/arm/v7) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

… you will also need to specify the platform in the `service` part:

```yaml
services:
freshrss:
image: freshrss/freshrss:arm
platform: linux/arm/v7
container_name: freshrss
```

## Run in production

For production, it is a good idea to use a reverse proxy on your host server, providing HTTPS.
Expand Down
21 changes: 0 additions & 21 deletions Docker/hooks/build

This file was deleted.

4 changes: 0 additions & 4 deletions Docker/hooks/post_checkout

This file was deleted.

11 changes: 0 additions & 11 deletions Docker/hooks/pre_build

This file was deleted.

2 changes: 0 additions & 2 deletions Makefile
Expand Up @@ -21,8 +21,6 @@ endif

ifeq ($(findstring alpine,$(TAG)),alpine)
DOCKERFILE=Dockerfile-Alpine
else ifeq ($(findstring arm,$(TAG)),arm)
DOCKERFILE=Dockerfile-QEMU-ARM
else
DOCKERFILE=Dockerfile
endif
Expand Down
6 changes: 2 additions & 4 deletions docs/en/developers/02_First_steps.md
Expand Up @@ -40,7 +40,7 @@ If you’re interested in the configuration, the `make` commands are defined in
If you need to use a different tag image (default is `alpine`), you can set the `TAG` environment variable:

```sh
TAG=arm make start
TAG=alpine make start
```

You can find the full list of available tags [on the Docker hub](https://hub.docker.com/r/freshrss/freshrss/tags).
Expand All @@ -49,11 +49,9 @@ If you want to build the Docker image yourself, you can use the following comman

```sh
make build
# or
TAG=arm make build
```

The `TAG` variable can be anything (e.g. `local`). You can target a specific architecture by adding `-alpine` or `-arm` at the end of the tag (e.g. `local-arm`).
The `TAG` variable can be anything (e.g. `local`). You can target a specific architecture by adding `-alpine` at the end of the tag (e.g. `local-alpine`).

## Project architecture

Expand Down
6 changes: 2 additions & 4 deletions docs/fr/developers/01_First_steps.md
Expand Up @@ -66,7 +66,7 @@ suivante la variable d’environnement `TAG` au moment de l’exécution de la
commande :

```sh
TAG=arm make start
TAG=alpine make start
```

Vous pouvez trouver la liste complète des tags disponibles [sur le hub
Expand All @@ -77,13 +77,11 @@ suivante :

```sh
make build
# ou
TAG=arm make build
```

La valeur de la variable `TAG` peut contenir n’importe quelle valeur (par
exemple `local`). Vous pouvez cibler une architecture spécifique en ajoutant
`-alpine` ou `-arm` à la fin du tag (par exemple `local-arm`).
`-alpine` à la fin du tag (par exemple `local-alpine`).

## Architecture du projet

Expand Down