-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from controllan/fix/ci-pipeline-and-map-copy
ci: improve pipeline and fix error in the mapcopy function.
- Loading branch information
Showing
4 changed files
with
58 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Docker | ||
name: Docker build & push | ||
|
||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
|
@@ -37,6 +37,9 @@ on: | |
|
||
run-name: "Build docker image [dry_run=${{ inputs.dry_run }}, ${{ vars.CONTAINER_REGISTRY_URL }}/${{ vars.CONTAINER_REGISTRY_REPOSITORY }}]" | ||
|
||
env: | ||
TEST_TAG: controllan/docker-state-exporter:test | ||
|
||
jobs: | ||
build: | ||
runs-on: [ self-hosted, ubuntu-latest, '${{ vars.RUNNER_LABEL_NAME }}' ] | ||
|
@@ -69,6 +72,36 @@ jobs: | |
with: | ||
images: ${{ vars.CONTAINER_REGISTRY_URL }}/${{ vars.CONTAINER_REGISTRY_REPOSITORY }} | ||
|
||
# Build test docker image | ||
# https://github.com/docker/build-push-action | ||
- name: Build test image [${{ env.TEST_TAG }}] | ||
uses: docker/[email protected] | ||
with: | ||
context: . | ||
load: true | ||
tags: ${{ env.TEST_TAG }} | ||
|
||
- name: Run docker image and verify if it is running | ||
env: | ||
IMAGE_TAG: ${{ env.TEST_TAG }} | ||
PORT: ${{ vars.DOCKER_TEST_PORT }} | ||
WAIT_TIME: ${{ vars.DOCKER_TEST_WAIT_TIME }} | ||
run: | | ||
docker compose up -d | ||
sleep $WAIT_TIME | ||
HEALTH_STATUS=$(docker inspect --format "{{json .State.Health }}" docker_state_exporter | jq -r ".Status") | ||
docker compose down -v | ||
if [ "$HEALTH_STATUS" != "healthy" ] | ||
then | ||
echo "Docker state exporter has an unhealthy status and therefore seems not to work." | ||
exit 1 | ||
fi | ||
shell: bash | ||
|
||
# Build and push Docker image with Buildx (don't push on PR) | ||
# https://github.com/docker/build-push-action | ||
- name: Build and push Docker image [${{ vars.CONTAINER_REGISTRY_URL }}/${{ vars.CONTAINER_REGISTRY_REPOSITORY }}] | ||
|
@@ -77,5 +110,5 @@ jobs: | |
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
push: ${{ (github.event_name != 'pull_request' || inputs.force_docker_push == true ) && inputs.dry_run != true }} | ||
tags: '${{ steps.meta.outputs.tags || inputs.tags }}${{ matrix.image_suffix }}' | ||
tags: '${{ steps.meta.outputs.tags || inputs.tags }}' | ||
labels: ${{ steps.meta.outputs.labels || inputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
version: '3.8' | ||
services: | ||
docker_state_exporter: | ||
image: ${IMAGE_TAG:-ghcr.io/controllan/docker-state-exporter:latest} | ||
container_name: docker_state_exporter | ||
volumes: | ||
- type: bind | ||
source: /var/run/docker.sock | ||
target: /var/run/docker.sock | ||
ports: | ||
- "${PORT:-8080}:${PORT:-8080}" | ||
command: | ||
- --no-add-container-labels # Keep this if you do not wand to add container labels. | ||
- --web.listen-address=:${PORT:-8080} # Set the port of the docker state exporter | ||
healthcheck: | ||
test: "wget -q -O - localhost:${PORT:-8080}/metrics | grep -q ',status=\"running\"} 1'" | ||
interval: 3s | ||
timeout: 10s | ||
retries: 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters