Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
austinwbest committed Nov 17, 2023
0 parents commit 3bc587a
Show file tree
Hide file tree
Showing 109 changed files with 9,968 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/Dockerfile
/LICENSE
/README.md
/.github
16 changes: 16 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base",
"docker:enableMajor",
"default:automergeDigest"
],
"packageRules": [
{
"matchDatasources": ["docker"],
"matchPackageNames": ["ubuntu"],
"matchUpdateTypes": ["minor", "patch", "pin", "digest"],
"automerge": true
}
]
}
67 changes: 67 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Docker

# This all came from github. I wrote none of it, but I did remove some bits that didn't work.

on:
push:
branches: [ "main" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "main" ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# 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
id: build-and-push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
88 changes: 88 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# syntax=docker/dockerfile:1

FROM ghcr.io/linuxserver/baseimage-alpine-nginx:3.18

# set version label
ARG BUILD_DATE
ARG VERSION
ARG NGINX_VERSION
LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
LABEL maintainer="aptalca"

# install packages
RUN \
if [ -z ${NGINX_VERSION+x} ]; then \
NGINX_VERSION=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.18/main/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \
&& awk '/^P:nginx$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://'); \
fi && \
apk add --no-cache \
memcached \
nginx==${NGINX_VERSION} \
nginx-mod-http-brotli==${NGINX_VERSION} \
nginx-mod-http-dav-ext==${NGINX_VERSION} \
nginx-mod-http-echo==${NGINX_VERSION} \
nginx-mod-http-fancyindex==${NGINX_VERSION} \
nginx-mod-http-geoip==${NGINX_VERSION} \
nginx-mod-http-geoip2==${NGINX_VERSION} \
nginx-mod-http-headers-more==${NGINX_VERSION} \
nginx-mod-http-image-filter==${NGINX_VERSION} \
nginx-mod-http-perl==${NGINX_VERSION} \
nginx-mod-http-redis2==${NGINX_VERSION} \
nginx-mod-http-set-misc==${NGINX_VERSION} \
nginx-mod-http-upload-progress==${NGINX_VERSION} \
nginx-mod-http-xslt-filter==${NGINX_VERSION} \
nginx-mod-mail==${NGINX_VERSION} \
nginx-mod-rtmp==${NGINX_VERSION} \
nginx-mod-stream==${NGINX_VERSION} \
nginx-mod-stream-geoip==${NGINX_VERSION} \
nginx-mod-stream-geoip2==${NGINX_VERSION} \
nginx-vim==${NGINX_VERSION} \
php82-bcmath \
php82-bz2 \
php82-dom \
php82-exif \
php82-ftp \
php82-gd \
php82-gmp \
php82-imap \
php82-intl \
php82-ldap \
php82-mysqli \
php82-mysqlnd \
php82-opcache \
php82-pdo_mysql \
php82-pdo_odbc \
php82-pdo_pgsql \
php82-pdo_sqlite \
php82-pear \
php82-pecl-apcu \
php82-pecl-memcached \
php82-pecl-redis \
php82-pgsql \
php82-posix \
php82-soap \
php82-sockets \
php82-sodium \
php82-sqlite3 \
php82-tokenizer \
php82-xmlreader \
php82-xsl && \
apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community \
php82-pecl-mcrypt && \
echo "**** configure php-fpm to pass env vars ****" && \
sed -E -i 's/^;?clear_env ?=.*$/clear_env = no/g' /etc/php82/php-fpm.d/www.conf && \
grep -qxF 'clear_env = no' /etc/php82/php-fpm.d/www.conf || echo 'clear_env = no' >> /etc/php82/php-fpm.d/www.conf && \
echo "env[PATH] = /usr/local/bin:/usr/bin:/bin" >> /etc/php82/php-fpm.conf

ARG INSTALL_PACKAGES=docker gzip
RUN apk add --update ${INSTALL_PACKAGES} && \
addgroup -g 281 unraiddocker && \
usermod -aG unraiddocker abc

# add local files
COPY root/ /

# ports and volumes
EXPOSE 80 443

VOLUME /config
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Docker Watcher

### Purpose
Simple UI driven way to manage updates & notifications for containers

### Notification triggers
- Notify when a container is added
- Notify when a container is removed
- Notify when a container changes state (running -> stopped)
- Nofity when an update is available
- Notify when an update is applied
- Notify if memory is > n%
- Notify if CPU is > n%

### Notification platforms
- Notifiarr

### Update options
- Ignore
- Auto update
- Check for update

### Container
`ghcr.io/notifiarr/dockwatch:main`

### ENV
These are my settings, adjust them to fit your setup!!

Volumes
| Name | Host | Container |
| ----- | ----- | ----- |
| App Config | /mnt/disk1/appdata/dockwatch/config | /config |
| Logs | /mnt/disk1/appdata/dockwatch/logs | /logs |
| Docker sock | /var/run/docker.sock | /var/run/docker.sock |
| WWW | /mnt/disk1/appdata/dockwatch/config/www | /config/www |

Ports
| Inside | Outside |
| ----- | ----- |
| 80 | 9999 |

Variables
| Name | Key | Value |
| ----- | ----- | ----- |
| PUID | PUID | 1001 |
| PGID | PGID | 100 |
| UMASK | UMASK | 022 |
| Mods | DOCKER_MODS | linuxserver/mods:universal-cron |

### Run
.....
96 changes: 96 additions & 0 deletions root/app/www/public/ajax/containers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php

/*
----------------------------------
------ Created: 111523 ------
------ Austin Best ------
----------------------------------
*/

require 'shared.php';

if ($_POST['m'] == 'init') {
?>
<div class="container-fluid pt-4 px-4">
<div class="bg-secondary rounded h-100 p-4">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th scope="col"></th>
<th scope="col">Name</th>
<th scope="col"></th>
<th scope="col">State</th>
<th scope="col">Added</th>
<th scope="col">Running</th>
<th scope="col">CPU</th>
<th scope="col">Memory</th>
<th scope="col">
<span onclick="$('#container-updates-all').toggle()" class="text-info" style="cursor: pointer;">Updates</span>
<select id="container-updates-all" style="display: none;" class="form-control" onchange="$('.container-updates').val($(this).val())">
<option value="0">Ignore</option>
<option value="1">Auto update</option>
<option value="2">Check for updates</option>
</select>
</th>
</tr>
</thead>
<tbody>
<?php
foreach ($processList as $process) {
$containerSettings = $settings['containers'][$process['Names']];
$logo = $process['inspect'][0]['Config']['Labels']['net.unraid.docker.icon'];
$control = $process['State'] == 'running' ? '<button type="button" class="btn btn-success me-2">Restart</button> <button type="button" class="btn btn-warning">Stop</button>' : '<button type="button" class="btn btn-success">start</button>';
?>
<tr>
<th scope="row"><?= ($logo ? '<img src="' . $logo . '" height="32" width="32">' : '') ?></th>
<td><?= $process['Names'] ?></td>
<td><?= $control ?></td>
<td><?= $process['State'] ?></td>
<td><?= $process['RunningFor'] ?></td>
<td><?= $process['Status'] ?></td>
<td><?= $process['stats']['CPUPerc'] ?></td>
<td><?= $process['stats']['MemPerc'] ?></td>
<td>
<select id="containers-update-<?= $process['Names'] ?>" class="form-control container-updates">
<option <?= ($containerSettings['updates'] == 0 ? 'selected' : '') ?> value="0">Ignore</option>
<option <?= ($containerSettings['updates'] == 1 ? 'selected' : '') ?> value="1">Auto update</option>
<option <?= ($containerSettings['updates'] == 2 ? 'selected' : '') ?> value="2">Check for updates</option>
</select>
</td>
</tr>
<?php
}
?>
</tbody>
<tfoot>
<tr>
<td colspan="9" align="center">
<button type="button" class="btn btn-info" onclick="saveContainerSettings()">Save</button>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<?php
}

if ($_POST['m'] == 'saveContainerSettings') {
$newSettings = [];

foreach ($_POST as $key => $val) {
if (strpos($key, 'containers-') === false) {
continue;
}

$container = str_replace('containers-update-', '', $key);
$newSettings[$container] = [
'updates' => $val
];
}

$settings['containers'] = $newSettings;
setSettingsFile($settings);
}
Loading

0 comments on commit 3bc587a

Please sign in to comment.