Skip to content

Commit

Permalink
Added tags to image build
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrink committed Dec 3, 2023
1 parent 8a121a7 commit 219d31a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 14 deletions.
42 changes: 34 additions & 8 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
name: Docker Image CI

on:
schedule:
- cron: "0 10 * * *"
push:
branches: [ "master" ]
branches:
- "master"
tags:
- "v*.*.*"
pull_request:
branches:
- "master"

jobs:
build:
Expand All @@ -13,7 +21,6 @@ jobs:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Docker Setup Buildx
uses: docker/setup-buildx-action@v3
with:
Expand All @@ -23,9 +30,28 @@ jobs:
with:
registry: https://ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get Short SHA
id: shortsha
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Build container
run: docker buildx build --push -t ghcr.io/${{github.repository}}:latest -t ghcr.io/${{github.repository}}:${{ github.sha }} -t ghcr.io/${{github.repository}}:${{ steps.shortsha.outputs.sha_short }} --platform linux/arm/v7,linux/arm64/v8 .
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/${{github.repository}}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule,pattern=nightly
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/arm/v7,linux/arm64/v8
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,19 +241,21 @@ I published the dashboard on [grafana.com](https://grafana.com/grafana/dashboard

### Docker

There is a Dockerfile available if you'd like to run as a docker container.
1. Use the published image

1.Building
```docker pull ghcr.io/tijmenvandenbrink/enviroplus_exporter```

2. Or build it yourself

```docker build -t enviroplus-exporter .```

2.Running
Or using [BuildKit](https://docs.docker.com/develop/develop-images/build_enhancements/) you can build Raspberry Pi compatible images on an amd64.

```docker run -d enviroplus-exporter -d -p 8000:8000 --device=/dev/i2c-1 --device=/dev/gpiomem --device=/dev/ttyAMA0 enviroplus-exporter```
```docker buildx build --platform linux/arm/v7,linux/arm64/v8 .```

Using [BuildKit](https://docs.docker.com/develop/develop-images/build_enhancements/) you can build Raspberry Pi compatible images on an amd64.
3. Running

```docker buildx build --platform linux/arm/v7,linux/arm64/v8 .```
```docker run -d enviroplus-exporter -d -p 8000:8000 --device=/dev/i2c-1 --device=/dev/gpiomem --device=/dev/ttyAMA0 enviroplus-exporter```

### Kubernetes

Expand Down

0 comments on commit 219d31a

Please sign in to comment.