Skip to content

Commit 6014e84

Browse files
committed
feat: add apps images for PostgreSQL and Uptime Kuma 2
1 parent b0972d4 commit 6014e84

File tree

3 files changed

+242
-0
lines changed

3 files changed

+242
-0
lines changed

.github/workflows/apps.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: build apps
2+
on:
3+
workflow_dispatch:
4+
workflow_run:
5+
workflows: [build base]
6+
types: [completed]
7+
branches:
8+
- master
9+
push:
10+
branches:
11+
- master
12+
paths:
13+
- apps/**
14+
- scripts/apps/**
15+
permissions:
16+
contents: read
17+
packages: write
18+
19+
jobs:
20+
check_changes:
21+
runs-on: ubuntu-latest
22+
outputs:
23+
postgresql_changed: ${{ steps.filter.outputs.postgresql_changed || 'false' }}
24+
uptime_kuma_2_changed: ${{ steps.filter.outputs.uptime_kuma_2_changed || 'false' }}
25+
base_changed: ${{ steps.filter.outputs.base_changed || 'false' }}
26+
steps:
27+
- if: ${{ github.event_name == 'push' }}
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
32+
- if: ${{ github.event_name == 'push' }}
33+
id: filter
34+
uses: dorny/paths-filter@v3
35+
with:
36+
filters: |
37+
postgresql_changed:
38+
- 'apps/postgresql/**'
39+
- 'scripts/apps/postgresql/**'
40+
uptime_kuma_2_changed:
41+
- 'apps/uptime-kuma-2/**'
42+
- 'scripts/apps/uptime-kuma-2/**'
43+
base_changed:
44+
- 'base/**'
45+
- 'scripts/base/ampstart.sh'
46+
47+
build_and_push:
48+
needs: [check_changes]
49+
if: ${{ github.repository_owner == 'CubeCoders' && github.ref == 'refs/heads/master' && ((github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') || (github.event_name == 'workflow_dispatch') || (github.event_name == 'push' && needs.check_changes.outputs.base_changed != 'true' && ((matrix.app == 'postgresql' && needs.check_changes.outputs.postgresql_changed == 'true') || (matrix.app == 'uptime-kuma-2' && needs.check_changes.outputs.uptime_kuma_2_changed == 'true'))) }}
50+
name: 'amp:apps-${{ matrix.app }}'
51+
runs-on: ubuntu-latest
52+
strategy:
53+
fail-fast: false
54+
matrix:
55+
app:
56+
- postgresql
57+
- uptime-kuma-2
58+
59+
steps:
60+
- uses: actions/checkout@v4
61+
with:
62+
ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.sha }}
63+
64+
- uses: docker/setup-qemu-action@v3
65+
- uses: docker/setup-buildx-action@v3
66+
67+
- uses: docker/login-action@v3
68+
with:
69+
username: ${{ vars.DOCKERHUB_USERNAME }}
70+
password: ${{ secrets.DOCKERHUB_TOKEN }}
71+
72+
- uses: docker/build-push-action@v6
73+
with:
74+
context: .
75+
file: ./apps/${{ matrix.app }}/Dockerfile
76+
platforms: linux/amd64,linux/arm64/v8
77+
push: true
78+
pull: true
79+
tags: cubecoders/ampbase:${{ matrix.app }}
80+
cache-from: type=gha,scope=${{ github.workflow }}-${{ matrix.app }}
81+
cache-to: type=gha,mode=max,scope=${{ github.workflow }}-${{ matrix.app }}
82+
provenance: mode=max
83+
sbom: true
84+
85+
concurrency:
86+
group: ${{ github.workflow }}-${{ github.ref }}
87+
cancel-in-progress: false

apps/uptime-kuma-2/Dockerfile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Uptime Kuma 2 image for AMP containers
2+
# Based on https://github.com/louislam/uptime-kuma/blob/223cde831f09a49a317bc4e5926cc8a38a6fa3f2/docker/debian-base.dockerfile
3+
# cubecoders/ampbase:uptime-kuma-2
4+
5+
FROM cubecoders/ampbase:debian
6+
7+
LABEL org.opencontainers.image.licenses=MIT
8+
9+
ENV UPTIME_KUMA_ENABLE_EMBEDDED_MARIADB="1"
10+
ENV AMP_ADDITIONAL_ENV_VARS="UPTIME_KUMA_ENABLE_EMBEDDED_MARIADB"
11+
ENV DEBIAN_FRONTEND="noninteractive"
12+
13+
# Install required packages
14+
RUN set -eux; \
15+
apt-get update; \
16+
# Install base dependencies
17+
apt-get install -o APT::Keep-Downloaded-Packages="false" -y --no-install-recommends \
18+
sqlite3 ca-certificates iputils-ping util-linux; \
19+
# Install Apprise for notifications
20+
wget -qO- http://ftp.debian.org/debian/pool/main/a/apprise/ | grep -oP 'href="apprise_.*?all\.deb"' | sed 's/href="//;s/"//' | sort -V | tail -n 1 | xargs -I {} wget -qO apprise.deb http://ftp.debian.org/debian/pool/main/a/apprise/{}; \
21+
apt-get install -o APT::Keep-Downloaded-Packages="false" -y --no-install-recommends \
22+
./apprise.deb python3-paho-mqtt; \
23+
rm -f apprise.deb; \
24+
# Install cloudflared
25+
install -d -m 0755 /etc/apt/keyrings; \
26+
wget -qO- https://pkg.cloudflare.com/cloudflare-main.gpg | gpg --dearmor -o /etc/apt/keyrings/cloudflare-main.gpg; \
27+
printf 'Types: deb\nURIs: https://pkg.cloudflare.com/cloudflared\nSuites: any\nComponents: main\nSigned-By: /etc/apt/keyrings/cloudflare-main.gpg\n' | tee /etc/apt/sources.list.d/cloudflared.sources >/dev/null; \
28+
apt update; \
29+
apt-get install -o APT::Keep-Downloaded-Packages="false" -y --no-install-recommends -t stable \
30+
cloudflared; \
31+
# Install remaining dependencies
32+
apt-get install -o APT::Keep-Downloaded-Packages="false" -y --no-install-recommends \
33+
chromium fonts-indic fonts-noto fonts-noto-cjk mariadb-server; \
34+
apt-get clean; \
35+
rm -rf /var/lib/apt/lists/*
36+
37+
COPY ./scripts/apps/uptime-kuma-2/ampstart.sh /ampstart.sh
38+
RUN chmod +x /ampstart.sh
39+
ENTRYPOINT ["/usr/bin/tini", "-g", "--", "/ampstart.sh"]
40+
CMD []
41+
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
5+
echo "[Info] AMPStart for Docker"
6+
ARCH=$(uname -m)
7+
8+
# Context check
9+
[ -z "${AMPUSERID}" ] && { echo "[Error] This docker image cannot be used directly by itself - it must be started by ampinstmgr"; exit 100; }
10+
11+
# Create /etc/machine-id (addresses Proton/dbus issues)
12+
mkdir -p /var/lib/dbus
13+
rm -f /etc/machine-id /var/lib/dbus/machine-id
14+
dbus-uuidgen --ensure=/etc/machine-id
15+
ln -s /etc/machine-id /var/lib/dbus/machine-id
16+
17+
# Set up amp user and group
18+
: "${AMPUSERID:?AMPUSERID not set}"
19+
: "${AMPGROUPID:?AMPGROUPID not set}"
20+
21+
echo "[Info] Setting up amp user and group..."
22+
23+
if ! getent group "${AMPGROUPID}" >/dev/null; then
24+
if getent group amp >/dev/null; then
25+
groupmod -o -g "${AMPGROUPID}" amp
26+
else
27+
groupadd -r -g "${AMPGROUPID}" amp
28+
fi
29+
fi
30+
31+
if id amp &>/dev/null; then
32+
usermod -o -u "${AMPUSERID}" -g "${AMPGROUPID}" amp
33+
else
34+
useradd -m -d /home/amp -s /bin/bash -c "AMP Process User" \
35+
-u "${AMPUSERID}" -g "${AMPGROUPID}" amp
36+
fi
37+
38+
getent group tty >/dev/null && usermod -aG tty amp
39+
40+
install -d -m 0755 /home/amp
41+
touch /home/amp/.gitconfig
42+
chown -R amp:amp /home/amp
43+
44+
# Make AMP binary executable
45+
AMP_BIN="/AMP/AMP_Linux_${ARCH}"
46+
chmod +x "${AMP_BIN}" || { echo "[Error] AMP binary not found or cannot be made executable"; exit 101; }
47+
48+
# Install extra dependencies if needed (non-fatal)
49+
REQUIRED_DEPS=()
50+
if [[ -n "${AMP_CONTAINER_DEPS:-}" ]]; then
51+
# shellcheck disable=SC2207
52+
REQUIRED_DEPS=($(jq -r '.[]? | select(type=="string" and length>0)' <<<"${AMP_CONTAINER_DEPS}" 2>/dev/null || echo))
53+
fi
54+
55+
if ((${#REQUIRED_DEPS[@]})); then
56+
echo "[Info] Installing extra dependencies..."
57+
(
58+
set +e
59+
apt-get update || echo "[Warn] apt-get update failed; continuing"
60+
apt-get install -y --no-install-recommends --allow-downgrades \
61+
-o APT::Keep-Downloaded-Packages="false" "${REQUIRED_DEPS[@]}" \
62+
|| echo "[Warn] apt-get install failed (bad package name?); continuing"
63+
apt-get clean >/dev/null 2>&1 || true
64+
rm -rf /var/lib/apt/lists/* || true
65+
)
66+
fi
67+
68+
# Set custom mountpoint permissions if needed (non-fatal)
69+
if [[ -n "${AMP_MOUNTPOINTS:-}" ]]; then
70+
echo "[Info] Updating custom mountpoint permissions..."
71+
IFS=':' read -r -a dirs <<< "${AMP_MOUNTPOINTS}"
72+
for dir in "${dirs[@]}"; do
73+
[[ -n "${dir}" ]] || continue
74+
if [[ -e "${dir}" ]]; then
75+
chown -R amp:"${AMPGROUPID}" "${dir}" 2>/dev/null || echo "[Warn] chown failed for ${dir}; continuing"
76+
else
77+
echo "[Warn] Mountpoint not found: ${dir}; skipping"
78+
fi
79+
done
80+
fi
81+
82+
# Run custom start script if it exists (non-fatal)
83+
if [[ -f "/AMP/customstart.sh" ]]; then
84+
echo "[Info] Running customstart.sh..."
85+
chmod +x /AMP/customstart.sh 2>/dev/null || true
86+
( set +e; /AMP/customstart.sh; rc=$?; ((rc==0)) || echo "[Warn] customstart.sh exited with $rc; continuing" )
87+
fi
88+
89+
# Addition for Uptime Kuma 2 (for embedded MySQL)
90+
chown -R amp:amp /var/lib/mysql
91+
92+
# Handoff
93+
echo "[Info] Starting AMP..."
94+
ARGS=$@
95+
keep_env=(
96+
HOME=/home/amp
97+
USER=amp LOGNAME=amp SHELL=/bin/bash
98+
LANG="${LANG:-en_US.UTF-8}" LANGUAGE="${LANGUAGE:-en_US:en}" LC_ALL="${LC_ALL:-en_US.UTF-8}"
99+
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
100+
MAIL=/var/mail/amp
101+
)
102+
# Always keep these AMP_ env vars if set
103+
for v in AMPHOSTPLATFORM AMP_CONTAINER AMP_CONTAINER_HOST_NETWORK AMPMEMORYLIMIT AMPSWAPLIMIT AMPCONTAINERCPUS; do
104+
if [[ -n "${!v-}" ]]; then keep_env+=("$v=${!v}"); fi
105+
done
106+
# Extra passthrough of env vars listed in AMP_ADDITIONAL_ENV_VARS in the Dockerfile
107+
if [[ -n "${AMP_ADDITIONAL_ENV_VARS-}" ]]; then
108+
for v in ${AMP_ADDITIONAL_ENV_VARS}; do
109+
if [[ -n "${!v-}" ]]; then keep_env+=("$v=${!v}"); fi
110+
done
111+
fi
112+
113+
exec gosu amp:amp env -i "${keep_env[@]}" \
114+
bash -c "cd /AMP && exec ${AMP_BIN} ${ARGS}"

0 commit comments

Comments
 (0)