diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..d6ac4d1 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,43 @@ + +name: Create and publish a Docker image to GitHub packages + +on: + push: + tags: + - "v*" + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-20.04 + + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 86c0dfd..146c971 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,6 @@ name: test -on: [pull_request] +on: [push, pull_request] jobs: unit-tests: diff --git a/README.md b/README.md index 24d4f12..ff66a21 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,15 @@ Repository that provides a dynamically configurable Prometheus exporter for Asterisk. The exporter uses the Asterisk Manager Interface (AMI) to communicate with Asterisk and YAML files to configure what data is scraped from Asterisk and what metrics are generated. This allows the exporter to be used with older Asterisk versions in different environments. ## Installation +### Docker +You can use the provided Docker image from GitHub Packages. \ +Run the Docker image and mount the configuration: +``` +docker run -p 8080:8080 -v ./config.yml:/home/dev/asterisk-prometheus-exporter/config.yml ghcr.io/gonicus/asterisk-prometheus-exporter:latest +``` +The configured metrics can be accessed at http://localhost:8080. \ +Alternatively, you can also create a Docker image using the provided Dockerfile. + ### Python Poetry The exporter uses Poetry as it's dependency management. Head over to [Poetry](https://python-poetry.org/) to install the latest version for your desired platform. @@ -20,18 +29,6 @@ By default, the exporter loads the configuration `config.yml` and uses port 8080 A different port can be specified via the first positional argument: `poetry run python src/main.py 9090`. \ A different configuration can be set using the `--config` option: `poetry run python src/main.py --config path/to/config.yml`. -### Docker -Create a Docker image using the provided Dockerfile: -``` -docker build --tag asterisk-prometheus-exporter . -``` - -Run the Docker image and mount the configuration: -``` -docker run -p 8080:8080 -v ./config.yml:/home/dev/asterisk-prometheus-exporter/config.yml asterisk-prometheus-exporter -``` -The configured metrics can be accessed at http://localhost:8080. - ## Configuration This section shows the rough structure of the configuration. See `src/config_schema.yml` for a detailed description of the configuration and what is possible.