Skip to content

Commit

Permalink
Add GitHub actions workflow for building container images and move to…
Browse files Browse the repository at this point in the history
… ghcr.io
  • Loading branch information
mtneug committed May 17, 2024
1 parent e480047 commit c7cb240
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 12 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/container-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: container-images

on:
push:
branches:
- main
tags:
- '**'
pull_request:
branches:
- main

jobs:
build-and-push:
runs-on: ubuntu-latest

env:
DOCKER_BUILDX_PLATFORM: linux/amd64

steps:
- uses: actions/checkout@v4

- name: set up Docker buildx
uses: docker/setup-buildx-action@v3
with:
platforms: ${{ env.DOCKER_BUILDX_PLATFORM }}

- uses: docker/login-action@v3
if: ${{ github.event_name == 'push' }}
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: info
run: |
docker version
docker info
echo '${{ github.ref_name }}' | sed -e 's/[^a-zA-Z0-9._-]/_/g' > VERSION_TAG
echo "version_tag=$(cat VERSION_TAG)"
- name: build
run: |
docker buildx build \
--load \
--platform "${DOCKER_BUILDX_PLATFORM}" \
\
--build-arg "VERSION=${{ github.ref_name }}" \
--build-arg "FFMPEG_VERSION=release" \
--build-arg "BUILD_DATE=$(date -u +"%Y-%m-%dT%TZ")" \
--build-arg "GIT_COMMIT=${{ github.sha }}" \
\
-t "ghcr.io/opencast/pyca:latest" \
-t "ghcr.io/opencast/pyca:main" \
-t "ghcr.io/opencast/pyca:${{ github.sha }}" \
-t "ghcr.io/opencast/pyca:$(cat VERSION_TAG)" \
.
- name: push release
if: ${{ github.ref_type == 'tag' }}
run: |
docker push "ghcr.io/opencast/pyca:$(cat VERSION_TAG)"
# assumption: last tag is always latest version
docker push "ghcr.io/opencast/pyca:latest"
- name: push dev version
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
run: |
docker push "ghcr.io/opencast/pyca:main"
- name: delete untagged container images
uses: snok/container-retention-policy@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
token-type: github-token
account-type: org
org-name: opencast
image-names: pyca
untagged-only: true
cut-off: 1 day ago UTC
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pypi: clean build
@printf "\nUpload to PyPI with \"twine upload dist/$$(python setup.py --fullname).tar.gz\"\n"

docker:
@docker build -t quay.io/opencast/pyca .
@docker build -t ghcr.io/opencast/pyca .

clean:
@python setup.py clean --all
Expand Down
2 changes: 1 addition & 1 deletion docs/install/container.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Install PyCA via Container

PyCA containers will automatically be built for each release and commit.
This can be used to easily deploy pyCA e.g. for capturing network streams.
The containers can be found at `quay.io/repository/opencast/pyca <https://quay.io/repository/opencast/pyca>`_.
The containers can be found at `ghcr.io/opencast/pyca <https://github.com/opencast/pyca/pkgs/container/pyca>`_.


Compose Files
Expand Down
10 changes: 5 additions & 5 deletions init/container/docker-compose.postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,39 @@ volumes:
services:
pyca-schedule:
command: schedule
image: quay.io/opencast/pyca
image: ghcr.io/opencast/pyca
restart: always
volumes:
- ./pyca.conf:/etc/pyca/pyca.conf:ro
- pyca:/var/lib/pyca

pyca-ingest:
command: ingest
image: quay.io/opencast/pyca
image: ghcr.io/opencast/pyca
restart: always
volumes:
- ./pyca.conf:/etc/pyca/pyca.conf:ro
- pyca:/var/lib/pyca

pyca-capture:
command: capture
image: quay.io/opencast/pyca
image: ghcr.io/opencast/pyca
restart: always
volumes:
- ./pyca.conf:/etc/pyca/pyca.conf:ro
- pyca:/var/lib/pyca

pyca-agentstate:
command: agentstate
image: quay.io/opencast/pyca
image: ghcr.io/opencast/pyca
restart: always
volumes:
- ./pyca.conf:/etc/pyca/pyca.conf:ro
- pyca:/var/lib/pyca

pyca-ui:
entrypoint: ["gunicorn", "--config=/etc/pyca/gunicorn.conf.py", "pyca.ui:app"]
image: quay.io/opencast/pyca
image: ghcr.io/opencast/pyca
restart: always
volumes:
- ./pyca.conf:/etc/pyca/pyca.conf:ro
Expand Down
10 changes: 5 additions & 5 deletions init/container/docker-compose.sqlite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,39 @@ volumes:
services:
pyca-schedule:
command: schedule
image: quay.io/opencast/pyca
image: ghcr.io/opencast/pyca
restart: always
volumes:
- ./pyca.conf:/etc/pyca/pyca.conf:ro
- pyca:/var/lib/pyca

pyca-ingest:
command: ingest
image: quay.io/opencast/pyca
image: ghcr.io/opencast/pyca
restart: always
volumes:
- ./pyca.conf:/etc/pyca/pyca.conf:ro
- pyca:/var/lib/pyca

pyca-capture:
command: capture
image: quay.io/opencast/pyca
image: ghcr.io/opencast/pyca
restart: always
volumes:
- ./pyca.conf:/etc/pyca/pyca.conf:ro
- pyca:/var/lib/pyca

pyca-agentstate:
command: agentstate
image: quay.io/opencast/pyca
image: ghcr.io/opencast/pyca
restart: always
volumes:
- ./pyca.conf:/etc/pyca/pyca.conf:ro
- pyca:/var/lib/pyca

pyca-ui:
entrypoint: ["gunicorn", "--config=/etc/pyca/gunicorn.conf.py", "pyca.ui:app"]
image: quay.io/opencast/pyca
image: ghcr.io/opencast/pyca
restart: always
volumes:
- ./pyca.conf:/etc/pyca/pyca.conf:ro
Expand Down

0 comments on commit c7cb240

Please sign in to comment.