项目作者: devatherock

项目描述 :
Badge generator for docker registries hosted in jfrog artifactory
高级语言: Groovy
项目地址: git://github.com/devatherock/artifactory-badge.git
创建时间: 2020-10-17T14:29:36Z
项目社区:https://github.com/devatherock/artifactory-badge

开源协议:MIT License

下载


CircleCI
Version
Coverage Status
Quality Gate
Docker Pulls
Docker Image Size
License: MIT

artifactory-badge

Badge generator for docker registries hosted in jfrog artifactory

Usage

Sample command

  1. docker run --rm \
  2. -p 8080:8080 \
  3. -e ARTIFACTORY_URL=https://some/url \
  4. -e ARTIFACTORY_API_KEY=xyz \
  5. devatherock/artifactory-badge:1.1.0

Configurable properties

application.yml

  1. logger:
  2. levels:
  3. io.micronaut.http.server.netty.NettyRequestLifecycle: DEBUG # Optional. To enable HTTP server access logs

Environment variables

Name Required Default Description
ARTIFACTORY_URL true (None) The JFrog artifactory URL that hosts the docker registry
ARTIFACTORY_API_KEY true (None) API key for interacting with artifactory’s REST API
ARTIFACTORY_EXCLUDED_FOLDERS false /_uploads Subfolders to be not treated as docker tags
ARTIFACTORY_DATE_FORMAT false yyyy-MM-dd’T’HH:mm:ss.SSSXXX Date format to parse dates in artifactory API responses
ARTIFACTORY_BADGE_SHIELDS_IO_ENABLED false true Indicates if shields.io should be used to generate the badge
ARTIFACTORY_BADGE_PARALLELISM false 5 Amount of parallelism to use when fetching details about versions of an image
LOGGER_LEVELS_ROOT false INFO SLF4J log level, for all(framework and custom) code
LOGGER_LEVELS_IO_GITHUB_DEVATHEROCK false INFO SLF4J log level, for custom code
MICRONAUT_ENVIRONMENTS false (None) Setting the value to local will mock the calls to the artifactory. Only for testing purposes
MICRONAUT_SERVER_PORT false 8080 Port in which the app listens on
MICRONAUT_CONFIG_FILES true (None) Path to YAML config files. The YAML files can be used to specify complex, object and array properties
LOGBACK_CONFIGURATION_FILE false (None) Class, file or remote path to logback configuration file. Will be ignored when using a remote path with any logger.* or LOGGER_ config set

API spec

When the app is running, detailed API documentation can be accessed at {host}/swagger-ui or {host}/swagger/artifactory-badge-{version}.yml. The available endpoints are listed below for reference:

  • /docker/pulls?package=path/to/package - Generates download count badge
  • /docker/image-size?package=path/to/package - Generates docker image size badge
  • /docker/layers?package=path/to/package - Generates docker image layers count badge
  • /version?package=path/to/package - Generates latest version badge

Sample badge generated by the custom generator

  1. <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="144" height="20" role="img" aria-label="docker pulls: 47">
  2. <title>docker pulls: 47</title>
  3. <linearGradient id="s" x2="0" y2="100%">
  4. <stop offset="0" stop-color="#bbb" stop-opacity=".1"></stop>
  5. <stop offset="1" stop-opacity=".1"></stop>
  6. </linearGradient>
  7. <clipPath id="r">
  8. <rect width="144" height="20" rx="3" fill="#fff"></rect>
  9. </clipPath>
  10. <g clip-path="url(#r)">
  11. <rect width="112" height="20" fill="#555"></rect>
  12. <rect x="112" width="32" height="20" fill="#007ec6"></rect>
  13. <rect width="144" height="20" fill="url(#s)"></rect>
  14. </g>
  15. <g font-family="monospace">
  16. <text aria-hidden="true" x="0" y="15" fill="#fff" xml:space="preserve"> docker pulls </text>
  17. <text aria-hidden="true" x="112" y="15" fill="#fff" xml:space="preserve"> 47 </text>
  18. </g>
  19. </svg>

Troubleshooting

Enabling debug logs

  • Set the environment variable LOGGER_LEVELS_ROOT to DEBUG to enable all debug logs - custom and framework
  • Set the environment variable LOGGER_LEVELS_IO_GITHUB_DEVATHEROCK to DEBUG to enable debug logs only in custom code
  • For fine-grained logging control, supply a custom logback.xml file
    and set the environment variable LOGBACK_CONFIGURATION_FILE to /path/to/custom/logback.xml

JSON logs

Refer logstash-logback-encoder documentation to customize the field names and formats in the log. To output logs as JSON, set the environment variable LOGBACK_CONFIGURATION_FILE to logback-json.xml