1
0
Fork 0
mirror of https://github.com/librenms/docker.git synced 2026-01-23 02:14:48 +00:00

Merge pull request #364 from crazy-max/container-logs-check

test: use composite container-logs-check action
This commit is contained in:
CrazyMax 2023-07-22 10:25:03 +02:00 committed by GitHub
commit c25f5076e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 49 additions and 128 deletions

View file

@ -1,7 +1,7 @@
name: build
concurrency:
group: build-${{ github.ref }}
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
@ -13,8 +13,6 @@ on:
paths-ignore:
- '**.md'
pull_request:
branches:
- 'master'
paths-ignore:
- '**.md'

View file

@ -1,5 +1,9 @@
name: labels
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:

View file

@ -1,84 +0,0 @@
name: test-edge
concurrency:
group: test-edge-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- 'master'
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
env:
BUILD_TAG: librenms-test
CONTAINER_NAME: librenms
RUNNING_TIMEOUT: 120
RUNNING_LOG_CHECK: ready to handle connections
jobs:
test:
runs-on: ubuntu-latest
continue-on-error: true
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Build
uses: docker/bake-action@v3
with:
targets: image-local
set: |
*.args.LIBRENMS_VERSION=master
env:
DEFAULT_TAG: ${{ env.BUILD_TAG }}
-
name: Start
run: |
docker compose up -d
working-directory: test
env:
LIBRENMS_IMAGE: ${{ env.BUILD_TAG }}
LIBRENMS_CONTAINER: ${{ env.CONTAINER_NAME }}
-
name: Test run
run: |
TIMEOUT=$((SECONDS + ${{ env.RUNNING_TIMEOUT }}))
while read LOGLINE; do
echo ${LOGLINE}
if [[ ${LOGLINE} == *"${{ env.RUNNING_LOG_CHECK }}"* ]]; then
echo "🎉 Container up!"
break
fi
if [[ $SECONDS -gt ${TIMEOUT} ]]; then
>&2 echo "❌ Failed to run ${{ env.CONTAINER_NAME }} container"
exit 1
fi
done < <(docker logs -f ${{ env.CONTAINER_NAME }} 2>&1)
CONTAINER_STATUS=$(docker container inspect --format "{{.State.Status}}" ${{ env.CONTAINER_NAME }})
if [[ ${CONTAINER_STATUS} != "running" ]]; then
>&2 echo "❌ Container ${{ env.CONTAINER_NAME }} returned status '$CONTAINER_STATUS'"
exit 1
fi
-
name: Logs
if: always()
run: |
docker compose logs
docker compose down --volumes > /dev/null 2>&1 || true
working-directory: test
env:
LIBRENMS_IMAGE: ${{ env.BUILD_TAG }}
LIBRENMS_CONTAINER: ${{ env.CONTAINER_NAME }}

View file

@ -1,7 +1,7 @@
name: test
concurrency:
group: test-${{ github.ref }}
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
@ -15,15 +15,25 @@ on:
- '**.md'
env:
BUILD_TAG: librenms-test
BUILD_TAG: librenms:test
CONTAINER_NAME: librenms
RUNNING_TIMEOUT: 120
RUNNING_LOG_CHECK: ready to handle connections
jobs:
test:
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.version == 'master' }}
strategy:
fail-fast: false
matrix:
version:
- ''
- master
steps:
-
name: Prepare
if: matrix.version != ''
run: |
echo "LIBRENMS_VERSION=${{ matrix.version }}" >> $GITHUB_ENV
-
name: Checkout
uses: actions/checkout@v3
@ -49,32 +59,17 @@ jobs:
LIBRENMS_IMAGE: ${{ env.BUILD_TAG }}
LIBRENMS_CONTAINER: ${{ env.CONTAINER_NAME }}
-
name: Test run
run: |
TIMEOUT=$((SECONDS + ${{ env.RUNNING_TIMEOUT }}))
while read LOGLINE; do
echo ${LOGLINE}
if [[ ${LOGLINE} == *"${{ env.RUNNING_LOG_CHECK }}"* ]]; then
echo "🎉 Container up!"
break
fi
if [[ $SECONDS -gt ${TIMEOUT} ]]; then
>&2 echo "❌ Failed to run ${{ env.CONTAINER_NAME }} container"
exit 1
fi
done < <(docker logs -f ${{ env.CONTAINER_NAME }} 2>&1)
CONTAINER_STATUS=$(docker container inspect --format "{{.State.Status}}" ${{ env.CONTAINER_NAME }})
if [[ ${CONTAINER_STATUS} != "running" ]]; then
>&2 echo "❌ Container ${{ env.CONTAINER_NAME }} returned status '$CONTAINER_STATUS'"
exit 1
fi
name: Check container logs
uses: crazy-max/.github/.github/actions/container-logs-check@main
with:
container_name: ${{ env.CONTAINER_NAME }}
log_check: "ready to handle connections"
timeout: 120
-
name: Logs
if: always()
run: |
docker compose logs
docker compose down --volumes > /dev/null 2>&1 || true
working-directory: test
env:
LIBRENMS_IMAGE: ${{ env.BUILD_TAG }}

View file

@ -407,10 +407,10 @@
> :warning: **UPGRADE NOTES**
> As the Docker container now runs as a non-root user, you have to first stop the container and change permissions to `data` volume:
> ```
> docker-compose stop
> docker compose stop
> chown -R ${PUID}:${PGID} data/
> docker-compose pull
> docker-compose up -d
> docker compose pull
> docker compose up -d
> ```
## 1.57-RC1 (2019/10/30)
@ -470,7 +470,7 @@
> :warning: **UPGRADE NOTES**
> Sidecar cron and syslog-ng are now respectively handled with `SIDECAR_CRON` and `SIDECAR_SYSLOGNG` env vars
> See docker-compose example and README for more info.
> See compose example and README for more info.
## 1.51-RC1 (2019/05/01)

View file

@ -115,6 +115,7 @@ RUN apk --update --no-cache add -t build-dependencies \
linux-headers \
musl-dev \
python3-dev \
&& echo "Installing LibreNMS https://github.com/librenms/librenms.git#${LIBRENMS_VERSION}..." \
&& git clone --depth=1 --branch ${LIBRENMS_VERSION} https://github.com/librenms/librenms.git . \
&& pip3 install --ignore-installed -r requirements.txt --upgrade \
&& COMPOSER_CACHE_DIR="/tmp" composer install --no-dev --no-interaction --no-ansi \

View file

@ -263,9 +263,9 @@ To upgrade to the latest version of LibreNMS, pull the newer image and launch
the container. LibreNMS will upgrade automatically:
```console
$ docker-compose down
$ docker-compose pull
$ docker-compose up -d
$ docker compose down
$ docker compose pull
$ docker compose up -d
```
## Configuration Management
@ -288,7 +288,7 @@ and will override the default values.
You can edit the running configuration via the LibreNMS web UI or `lnms config:set`
```bash
docker-compose exec librenms lnms config:set page_refresh 300
docker compose exec librenms lnms config:set page_refresh 300
```
### Re-Apply YAML Config
@ -317,7 +317,7 @@ If you want to use the `lnms` command to perform common server operations like
manage users, database migration, and more, type:
```console
$ docker-compose exec librenms lnms
$ docker compose exec librenms lnms
```
### Validate
@ -326,7 +326,7 @@ If you want to validate your installation from the CLI, type the following
command:
```console
$ docker-compose exec --user librenms librenms php validate.php
$ docker compose exec --user librenms librenms php validate.php
====================================
Component | Version
--------- | -------
@ -350,8 +350,8 @@ SNMP | NET-SNMP 5.8
If you want to enable the new [Dispatcher service](https://docs.librenms.org/Extensions/Dispatcher-Service/),
you have to run a "sidecar" container (see dispatcher service in
[docker-compose.yml](examples/compose/docker-compose.yml) example) or run a
simple container like this:
[compose.yml](examples/compose/compose.yml) example) or run a simple container
like this:
```console
$ docker run -d --name librenms_dispatcher \
@ -369,8 +369,8 @@ $ docker run -d --name librenms_dispatcher \
### Syslog-ng container
If you want to enable syslog-ng, you have to run a "sidecar" container (see
syslog-ng service in [docker-compose.yml](examples/compose/docker-compose.yml)
example) or run a simple container like this:
syslog-ng service in [compose.yml](examples/compose/compose.yml) example) or
run a simple container like this:
```console
$ docker run -d --name librenms_syslog \
@ -395,8 +395,8 @@ enable_syslog: true
### Snmptrapd container
If you want to enable snmptrapd, you have to run a "sidecar" container (see
snmptrapd service in [docker-compose.yml](examples/compose/docker-compose.yml)
example) or run a simple container like this:
snmptrapd service in [compose.yml](examples/compose/compose.yml) example) or
run a simple container like this:
```console
$ docker run -d --name librenms_snmptrapd \

View file

@ -2,9 +2,16 @@ variable "DEFAULT_TAG" {
default = "librenms:local"
}
variable "LIBRENMS_VERSION" {
default = null
}
// Special target: https://github.com/docker/metadata-action#bake-definition
target "docker-metadata-action" {
tags = ["${DEFAULT_TAG}"]
args = {
LIBRENMS_VERSION = LIBRENMS_VERSION
}
}
// Default target if none specified