Skip to content

Commit

Permalink
Adjust docker labels to modern OCI schema (#7773)
Browse files Browse the repository at this point in the history
* adapt namespace

* add new labels

* make baseimage available for labels

* remove unneeded ending

* ensure image name is correct for ghcrio

* ensure the right outputs are used

* fix reference

* fix assigment

* only push docker reg image if authd

* swith back to env

this gets provided by the version ci script

* make repo targets changeable

* make readable

* revert ghcr.io change
  • Loading branch information
matmair authored Aug 11, 2024
1 parent 6cf5684 commit 41f6dd6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
6 changes: 5 additions & 1 deletion .github/scripts/version_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"""

import itertools
import json
import os
import re
Expand Down Expand Up @@ -198,10 +199,13 @@ def check_version_number(version_string, allow_duplicate=False):
print(f"Version check passed for '{version}'!")
print(f"Docker tags: '{docker_tags}'")

target_repos = [REPO.lower(), f'ghcr.io/{REPO.lower()}']

# Ref: https://getridbug.com/python/how-to-set-environment-variables-in-github-actions-using-python/
with open(os.getenv('GITHUB_ENV'), 'a') as env_file:
# Construct tag string
tags = ','.join([f'{REPO.lower()}:{tag}' for tag in docker_tags])
tag_list = [[f'{r}:{t}' for t in docker_tags] for r in target_repos]
tags = ','.join(itertools.chain(*tag_list))

env_file.write(f'docker_tags={tags}\n')

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ jobs:
id: docker_login
run: |
if [ -z "${{ secrets.DOCKER_USERNAME }}" ]; then
echo "skip_dockerhub_login=true" >> $GITHUB_ENV
echo "skip_dockerhub_login=true" >> $GITHUB_OUTPUT
else
echo "skip_dockerhub_login=false" >> $GITHUB_ENV
echo "skip_dockerhub_login=false" >> $GITHUB_OUTPUT
fi
- name: Login to Dockerhub
if: github.event_name != 'pull_request' && steps.docker_login.outputs.skip_dockerhub_login != 'true'
Expand Down
20 changes: 13 additions & 7 deletions contrib/container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

ARG base_image=python:3.11-alpine3.18
FROM ${base_image} AS inventree_base
ARG base_image

# Build arguments for this image
ARG commit_tag=""
Expand Down Expand Up @@ -48,13 +49,18 @@ ENV INVENTREE_BACKGROUND_WORKERS="4"
ENV INVENTREE_WEB_ADDR=0.0.0.0
ENV INVENTREE_WEB_PORT=8000

LABEL org.label-schema.schema-version="1.0" \
org.label-schema.build-date=${DATE} \
org.label-schema.vendor="inventree" \
org.label-schema.name="inventree/inventree" \
org.label-schema.url="https://hub.docker.com/r/inventree/inventree" \
org.label-schema.vcs-url="https://github.com/inventree/InvenTree.git" \
org.label-schema.vcs-ref=${commit_tag}
LABEL org.opencontainers.image.created=${DATE} \
org.opencontainers.image.vendor="inventree" \
org.opencontainers.image.title="InvenTree backend server" \
org.opencontainers.image.description="InvenTree is the open-source inventory management system" \
org.opencontainers.image.url="https://inventree.org" \
org.opencontainers.image.documentation="https://docs.inventree.org" \
org.opencontainers.image.source="https://github.com/inventree/InvenTree" \
org.opencontainers.image.revision=${commit_hash} \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.base.name="docker.io/library/${base_image}" \
org.opencontainers.image.version=${commit_tag}


# Install required system level packages
RUN apk add --no-cache \
Expand Down

0 comments on commit 41f6dd6

Please sign in to comment.