Skip to content

Commit

Permalink
refactor(structure)!: new image name
Browse files Browse the repository at this point in the history
* anki-sync-server now named anki-sync-server not oci-anki-sync
* multi-arch builds
  * convert docker-style to cargo-style
  * cross-compile on linux/amd64
  * install gcc cross-compiler + rustup target for target arch
  * build glibc applications

BREAKING CHANGE: new container name
Signed-off-by: Frederik Zorn <federdaemn@mail.de>
  • Loading branch information
z0rrn committed Nov 12, 2023
1 parent 03e0d51 commit de09e63
Show file tree
Hide file tree
Showing 12 changed files with 245 additions and 149 deletions.
12 changes: 0 additions & 12 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,3 @@ updates:
# prefix all commit messages with "chore(deps): "
commit-message:
prefix: "chore(deps): "

# Create a group of dependencies to be updated together in one pull request
groups:
# Update all dependencies from redhat-actions together
redhat-actions:
patterns:
- "redhat-actions/*"

# Update all non-specified dependencies together
all:
patterns:
- "*"
115 changes: 69 additions & 46 deletions .github/workflows/container-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: Apache-2.0

name: 'Build and push anki-sync container'
name: 'Build and push image'

# run workflow on every branch, only upload on main (allow manual trigger)
on: [push, pull_request, workflow_dispatch]
Expand All @@ -27,29 +27,35 @@ jobs:
uses: mikefarah/yq@v4

- name: Setup oras
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
uses: oras-project/setup-oras@v1

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

- name: Login to GitHub Container Registry
uses: redhat-actions/podman-login@v1
uses: docker/login-action@v3
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
with:
registry: ghcr.io
username: federdaemn
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to DockerHub
uses: redhat-actions/podman-login@v1
uses: docker/login-action@v3
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
with:
registry: docker.io
username: federdaemn
password: ${{ secrets.DOCKER_TOKEN }}

- name: Set outputs for later use
id: set-op
run: |
# extract version from ./values.yml
echo "anki-version=$(yq '.version.anki-version' ./values.yml)" \
echo "software-version=$(yq '.version.software-version' ./anki-sync-server/values.yml)" \
>> $GITHUB_OUTPUT
# get current date+time
Expand All @@ -58,59 +64,76 @@ jobs:
# get current date+time docker tag compatible
echo "time-docker=$(date --utc +'%Y-%m-%dt%H-%M-%Sz')" >> $GITHUB_OUTPUT
- name: Build image
id: build_image
uses: redhat-actions/buildah-build@v2
- name: Build and push image in production
uses: docker/build-push-action@v5
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
with:
# directly push image
push: true

# use local repository
context: .

# which containerfile to build from
containerfiles: |
./containerfile
file: |
./anki-sync-server/containerfile
# build args to pass to the build
build-args: |
software_version=${{ steps.set-op.outputs.software-version }}
# build for many platforms at the same time
platforms: |
linux/amd64
linux/arm64
# set labels to append to the image
labels: |
# opencontainer labels specified
# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
org.opencontainers.image.title=oci-anki-sync
org.opencontainers.image.description=Anki sync server (anki-sync-server) in a container
org.opencontainers.image.authors=Frederik Zorn <federdaemnmail.de>
org.opencontainers.image.created=${{ steps.set-op.outputs.time }}
org.opencontainers.image.version=${{ steps.set-op.outputs.anki-version }}
org.opencontainers.image.licenses=AGPL-3.0-or-later
org.opencontainers.image.url=https://github.com/federdaemn/oci-anki-sync
org.opencontainers.image.source=https://github.com/federdaemn/oci-anki-sync
# artfifacthub labels specified
# https://artifacthub.io/docs/topics/repositories/container-images/#image-metadata
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/federdaemn/oci-anki-sync/main/README.md
io.artifacthub.package.maintainers=[{"name":"federdaemn","email":"federdaemn@mail.de"}]
io.artifacthub.package.keywords=anki,sync,server,anki-sync-server,anki-sync
io.artifacthub.package.logo-url=https://raw.githubusercontent.com/federdaemn/oci-anki-sync/main/imgs/anki/logo.png
io.artifacthub.package.alternative-locations=docker.io/federdaemn/oci-anki-sync
# build args to pass to the build
build-args: |
anki_version=${{ steps.set-op.outputs.anki-version }}
org.opencontainers.image.version=${{ steps.set-op.outputs.software-version }}
# tags to build the image with
tags: |
ghcr.io/federdaemn/oci-anki-sync:latest
ghcr.io/federdaemn/oci-anki-sync:${{ steps.set-op.outputs.anki-version }}
ghcr.io/federdaemn/oci-anki-sync:${{ steps.set-op.outputs.time-docker }}
docker.io/federdaemn/oci-anki-sync:latest
docker.io/federdaemn/oci-anki-sync:${{ steps.set-op.outputs.anki-version }}
docker.io/federdaemn/oci-anki-sync:${{ steps.set-op.outputs.time-docker }}
- name: Push image
uses: redhat-actions/push-to-registry@v2
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
with:
tags: ${{ steps.build_image.outputs.tags }}
ghcr.io/federdaemn/anki-sync-server:latest
ghcr.io/federdaemn/anki-sync-server:${{ steps.set-op.outputs.software-version }}
ghcr.io/federdaemn/anki-sync-server:${{ steps.set-op.outputs.time-docker }}
docker.io/federdaemn/anki-sync-server:latest
docker.io/federdaemn/anki-sync-server:${{ steps.set-op.outputs.software-version }}
docker.io/federdaemn/anki-sync-server:${{ steps.set-op.outputs.time-docker }}
# use oras to push artifacthub metadata to ghcr.io
- name: Build image in testing only
uses: docker/build-push-action@v5
if: github.event_name == 'pull_request'
with:
# do not push image
push: false

# use local repository
context: .

# which containerfile to build from
file: |
./anki-sync-server/containerfile
# build args to pass to the build
build-args: |
software_version=${{ steps.set-op.outputs.software-version }}
# build for many platforms at the same time
platforms: |
linux/amd64
linux/arm64
# use oras to push artifacthub metadata to registries
# source: https://artifacthub.io/docs/topics/repositories/container-images/#repository-metadata
- name: Push metadata
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
run: |
oras push \
ghcr.io/federdaemn/oci-anki-sync:artifacthub.io \
ghcr.io/federdaemn/anki-sync-server:artifacthub.io \
--config /dev/null:application/vnd.cncf.artifacthub.config.v1+yaml \
anki-sync-server/artifacthub-repo.yml:application/vnd.cncf.artifacthub.repository-metadata.layer.v1.yaml
oras push \
docker.io/federdaemn/anki-sync-server:artifacthub.io \
--config /dev/null:application/vnd.cncf.artifacthub.config.v1+yaml \
artifacthub-repo.yml:application/vnd.cncf.artifacthub.repository-metadata.layer.v1.yaml
anki-sync-server/artifacthub-repo.yml:application/vnd.cncf.artifacthub.repository-metadata.layer.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: Apache-2.0

name: 'Update anki version in values.yml'
name: 'Update anki-sync-server version in values.yml (GH API)'

# run workflow every monday at 00:00 UTC
on:
Expand All @@ -12,7 +12,7 @@ on:

jobs:
update-version:
name: Update anki version in values.yml
name: Update anki-sync-server version in values.yml

# use ubuntu as runner
runs-on: ubuntu-latest
Expand All @@ -34,10 +34,10 @@ jobs:
- name: Setup yq
uses: mikefarah/yq@v4

- name: Get current anki version
id: anki-version
- name: Get current anki-sync-server version
id: set-op
run: |
echo "anki-version=$(yq '.version.anki-version' ./values.yml)" \
echo "software-version=$(yq '.version.software-version' ./anki-sync-server/values.yml)" \
>> $GITHUB_OUTPUT
- name: Fetch GH API and get tag_name from latest release
Expand All @@ -53,18 +53,18 @@ jobs:
# set output for later use
echo "name=$tag_name" >> $GITHUB_OUTPUT
- name: Set new anki version in values.yml
if: ${{ steps.anki-version.outputs.anki-version != steps.get-release.outputs.name }}
- name: Set new anki-sync-server version in values.yml
if: ${{ steps.set-op.outputs.software-version != steps.get-release.outputs.name }}
run: |
yq -i '.version.anki-version = "${{ steps.get-release.outputs.name }}"' \
./values.yml
yq -i '.version.software-version = "${{ steps.get-release.outputs.name }}"' \
./anki-sync-server/values.yml
- name: Set up git email/name a. commit changes
if: ${{ steps.anki-version.outputs.anki-version != steps.get-release.outputs.name }}
if: ${{ steps.set-op.outputs.software-version != steps.get-release.outputs.name }}
run: |
git config user.name federdaemn-bot
git config user.email federdaemn@mail.de
git add ./values.yml
git commit -m "chore(anki): bump anki version to ${{ steps.get-release.outputs.name }}" \
git add ./anki-sync-server/values.yml
git commit -m "chore(anki-sync-server): bump version to ${{ steps.get-release.outputs.name }}" \
-m "Signed-off-by: github-actions in the name of Frederik Zorn <federdaemn@mail.de>"
git push origin main
6 changes: 3 additions & 3 deletions .reuse/dep5
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: oci-anki-sync
Upstream-Name: docker-anki-sync-server
Upstream-Contact: Frederik Zorn <federdaemn@mail.de>
Source: https://github.com/federdaemn/oci-anki-sync
Source: https://github.com/federdaemn/docker-anki-sync-server

# Sample paragraph, commented out:
#
Expand All @@ -13,6 +13,6 @@ Files: .vscode/*
Copyright: 2023 Frederik Zorn <federdaemn@mail.de>
License: Apache-2.0

Files: imgs/anki/logo.png
Files: anki-sync-server/imgs/ah-logo.png
Copyright: Alex Fraser https://apps.ankiweb.net/
License: LicenseRef-anki-logo
48 changes: 34 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,30 @@ SPDX-FileCopyrightText: 2023 Frederik Zorn <federdaemn@mail.de>
SPDX-License-Identifier: Apache-2.0
-->

# oci-anki-sync (anki-sync-server docker container) repository
# docker anki-sync-server repository

This contains a Dockerfile and Ci scripts to build a container image for
This contains a dockerfile and CI/CD scripts to build a container image for
[Anki Sync Server](https://apps.ankiweb.net/) using a scratch image as base
image.

## Warning

This image is not official. Use at your own risk.

## Images

## Host Architecture

This image is cross-compiled and thus available for

* linux/amd64
* linux/arm64

I sadly can not build for linux/arm/v7
(because of [build errors](https://github.com/rust-lang/cargo/issues/9545#issue-911773248))
and for linux/riscv64 (because of missing
[rust](https://hub.docker.com/_/rust/tags) container support).

## Updates and Versions

* The container is auto-updated every Monday whenever a new version of anki is
Expand All @@ -26,34 +44,36 @@ can forget this project exists :).
### Git

This project is hosted on [GitHub](https://github.com) at the
[federdaemn/oci-anki-sync](https://github.com/federdaemn/oci-anki-sync) project.
[federdaemn/docker-anki-sync-server](https://github.com/federdaemn/docker-anki-sync-server)
project.

### Container Registry

The container images are hosted on
[GitHub Container Registry](https://github.com/federdaemn/oci-anki-sync/pkgs/container/oci-anki-sync)
You can find this image on
[GitHub Container Registry](https://github.com/federdaemn/docker-anki-sync-server/pkgs/container/anki-sync-server)
(recommended) and on
[Docker Hub](https://hub.docker.com/r/federdaemn/oci-anki-sync) for redundancy.
Additionally, the container images are also listed on
[artifacthub.io](https://artifacthub.io) with the package name
[`oci-anki-sync`](https://artifacthub.io/packages/container/oci-anki-sync/oci-anki-sync).
[Docker Hub](https://hub.docker.com/r/federdaemn/anki-sync-server) for
redundancy. The Artifact Hub name is
[`anki-sync-server`](https://artifacthub.io/packages/container/anki-sync-server/anki-sync-server).

There are three tags available on both registries:
There are four tags available:

* `latest`: Always the latest version of anki.
* `<anki-version>`: The version specified of anki.
* `<time-of-build>`: The exact time(+date) when the container was built
* `<time-of-build>`: The exact time (+ date) when the container was built
(using (`date` syntax): %Y-%m-%dt%H-%M-%Sz).
* `artifacthub.io`: You may ignore this. This is just for Artifact Hub Verified
Publisher.

## Setup

* See SETUP.md for detailed instructions.

## Contributing

* Contributions for newer versions or files are gracefully accepted but the
scope is to only generate an auto-updating docker/oci container.
* Please try to wrap lines at 80 characters.
* Contributions for newer versions or files are gracefully accepted. Even things
like small speed improvements are helpfull.
* Please try to wrap all lines at 80 characters.

## License

Expand Down
17 changes: 9 additions & 8 deletions SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,30 @@ version: "3.7"

services:

oci-anki-sync:
# https://github.com/federdaemn/oci-anki-sync/blob/main/SETUP.md
image: ghcr.io/federdaemn/oci-anki-sync:2.1.66
container_name: oci-anki-sync
anki-sync-server:
# https://github.com/federdaemn/anki-sync-server/blob/main/SETUP.md
image: ghcr.io/federdaemn/anki-sync-server:2.1.66
container_name: anki-sync-server
restart: unless-stopped
# these are sample passwords, please change them
environment:
- SYNC_USER1=panda:rsfPz4NXELBxmJ
- SYNC_USER2=penguin:2Qtf5nnsDpsQ3b
volumes:
- oci-anki-sync:/config
- anki-sync-server:/config
ports:
- 22701:22701

volumes:
oci-anki-sync:
anki-sync-server:
```
* the important parts are
* set SYNC_USERX to your desired username and password
* mount volume oci-anki-sync to /config
* mount volume anki-sync-server to /config
* open port 22701
**for more configuration options see <https://docs.ankiweb.net/sync-server.html>**
If you know how to configure another reverse-proxy please open an issue/pull request
If you know how to configure another reverse-proxy please open an issue/pull
request.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#

# optional, enables verified publisher
repositoryID: 1c0df0d3-21af-4cb9-aaae-663cdaf93807
repositoryID: 0e6be73b-431a-4bd8-9220-26400991eee6

# optional, used to claim repository ownership
owners:
Expand Down
Loading

0 comments on commit de09e63

Please sign in to comment.