diff --git a/.env.dist b/.env.dist index 961d56c..85b43ba 100644 --- a/.env.dist +++ b/.env.dist @@ -1,2 +1,13 @@ -LITESTREAM_TEMPLATE=basic -LITESTREAM_DATA_DIR=/data +LITESTREAM_TEMPLATE=s3 +LITESTREAM_DB_FILE=/app/data/kuma.db +LITESTREAM_S3_ENDPOINT=yourbucket.minio.tld +LITESTREAM_S3_REGION=foobar +LITESTREAM_S3_BUCKET=foobar +LITESTREAM_S3_PATH=foobar +LITESTREAM_S3_ACCESS_KEY_ID=foobar +LITESTREAM_S3_SECRET_ACCESS_KEY=foobarbaz +LITESTREAM_RETENTION=24h +LITESTREAM_RETENTION_CHECK_INTERVAL=1h +LITESTREAM_SNAPSHOT_INTERVAL=10s +LITESTREAM_SYNC_INTERVAL=1s +LITESTREAM_VALIDATION_INTERVAL=12h diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index b67d764..3482011 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -13,14 +13,37 @@ permissions: contents: read jobs: + test: + name: "Test" + runs-on: "ubuntu-latest" + + steps: + - name: "Checkout" + uses: actions/checkout@v4 + + - name: "Set up Docker Buildx" + uses: docker/setup-buildx-action@v3 + + - name: "Build image" + uses: docker/build-push-action@v6 + with: + context: "." + load: true + tags: "dockette/kumatron:latest" + + - name: "Test image" + run: "make test" + build: name: "Build" + needs: ["test"] + if: github.ref == 'refs/heads/master' uses: dockette/.github/.github/workflows/docker.yml@master secrets: inherit with: - image: "dockette/kumatron" - tag: "${{ matrix.tag }}" - context: "${{ matrix.context }}" + image: "dockette/kumatron" + tag: "${{ matrix.tag }}" + context: "${{ matrix.context }}" strategy: matrix: include: @@ -30,3 +53,20 @@ jobs: context: . fail-fast: false + + docs: + name: "Docs" + runs-on: "ubuntu-latest" + needs: ["build"] + if: github.ref == 'refs/heads/master' + + steps: + - name: "Checkout" + uses: actions/checkout@v4 + + - name: "Update Docker Hub description" + uses: peter-evans/dockerhub-description@v5 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + repository: "dockette/kumatron" diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..d5c338d --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,36 @@ +# AGENTS.md + +## Project + +Dockette image for Uptime Kuma with optional Litestream support for streaming SQLite backups to remote storage such as S3. + +## Image + +- Docker image: `dockette/kumatron`. +- Build context is the repository root and `Dockerfile` is the only image definition. +- Runtime base is `louislam/uptime-kuma:1.23.16-debian`. +- Builder stages download Litestream `v0.3.13` and `envsubst`, then copy them into the runtime image. +- Runtime data defaults to `DATA_DIR=./data/`; `/app/data` is created by the image. +- GitHub Actions publishes `latest` and `20250502` from the root context. + +## Commands + +- `make build` builds `dockette/kumatron:${DOCKER_TAG}`. +- `make test` starts `kumatron-test` and probes the app with Node over `DOCKER_TEST_PORT`. +- `make run` starts the image on `${DOCKER_TEST_PORT}:3001` as container `kumatron`. +- `make enter` opens a shell in the running `kumatron` container. +- `make test-s3` runs with Litestream S3 environment variables from `.env.dist` and optional `.env`. + +## Testing + +- Use `make -n build test run` to dry-run the default commands before changing build logic. +- A real `make test` needs Docker and a built local image; it removes `kumatron-test` on success or failure. +- Litestream S3 testing needs valid `.env` values and should not commit secrets. + +## Guidelines + +- Keep `Dockerfile`, `entrypoint.sh`, `litestream/`, `Makefile`, README examples, and `.github/workflows/docker.yml` aligned. +- Prefer `DOCKER_*` names for Docker-related Makefile variables. +- Place `.PHONY: ` directly above each Makefile target. +- Preserve Litestream environment variable names because README examples and templates depend on them. +- Do not introduce unrelated formatting or structural changes. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..43c994c --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1 @@ +@AGENTS.md diff --git a/Makefile b/Makefile index 2686e5d..b0d498d 100644 --- a/Makefile +++ b/Makefile @@ -3,25 +3,49 @@ include .env.dist -include .env export +DOCKER_IMAGE=dockette/kumatron +DOCKER_TAG?=latest +DOCKER_TEST_PORT?=3001 + + +.PHONY: build build: - docker build -t dockette/kumatron . + docker build -t ${DOCKER_IMAGE}:${DOCKER_TAG} . +.PHONY: enter enter: docker exec -it kumatron bash +.PHONY: test test: + docker rm -f kumatron-test >/dev/null 2>&1 || true + docker run -d --name kumatron-test ${DOCKER_IMAGE}:${DOCKER_TAG} + for i in $$(seq 1 60); do \ + if docker exec kumatron-test node -e "require('http').get('http://127.0.0.1:${DOCKER_TEST_PORT}', (res) => process.exit(res.statusCode >= 200 && res.statusCode < 500 ? 0 : 1)).on('error', () => process.exit(1))"; then \ + docker rm -f kumatron-test >/dev/null; \ + exit 0; \ + fi; \ + sleep 2; \ + done; \ + docker logs kumatron-test; \ + docker rm -f kumatron-test >/dev/null; \ + exit 1 + +.PHONY: run +run: docker run \ -it \ --rm \ - -p 3001:3001 \ + -p ${DOCKER_TEST_PORT}:3001 \ --name kumatron \ - dockette/kumatron + ${DOCKER_IMAGE}:${DOCKER_TAG} +.PHONY: test-s3 test-s3: docker run \ -it \ --rm \ - -p 3001:3001 \ + -p ${DOCKER_TEST_PORT}:3001 \ -e LITESTREAM=1 \ -e LITESTREAM_TEMPLATE=${LITESTREAM_TEMPLATE} \ -e LITESTREAM_DB_FILE=${LITESTREAM_DB_FILE} \ @@ -31,5 +55,10 @@ test-s3: -e LITESTREAM_S3_PATH=${LITESTREAM_S3_PATH} \ -e LITESTREAM_S3_ACCESS_KEY_ID=${LITESTREAM_S3_ACCESS_KEY_ID} \ -e LITESTREAM_S3_SECRET_ACCESS_KEY=${LITESTREAM_S3_SECRET_ACCESS_KEY} \ + -e LITESTREAM_RETENTION=${LITESTREAM_RETENTION} \ + -e LITESTREAM_RETENTION_CHECK_INTERVAL=${LITESTREAM_RETENTION_CHECK_INTERVAL} \ + -e LITESTREAM_SNAPSHOT_INTERVAL=${LITESTREAM_SNAPSHOT_INTERVAL} \ + -e LITESTREAM_SYNC_INTERVAL=${LITESTREAM_SYNC_INTERVAL} \ + -e LITESTREAM_VALIDATION_INTERVAL=${LITESTREAM_VALIDATION_INTERVAL} \ --name kumatron \ - dockette/kumatron + ${DOCKER_IMAGE}:${DOCKER_TAG} diff --git a/README.md b/README.md index 6f3f022..9e130c5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,12 @@

Dockette / Kumatron

+

+ GitHub Actions + Docker Hub pulls + GitHub Sponsors + Support/Discussions +

+

🐳 Uptime Kuma with extra juicy configuration and streaming SQLite.

@@ -57,14 +64,15 @@ docker run \ ## Development -See [how to contribute](https://contributte.org/contributing.html) to this package. - -This package is currently maintaining by these authors. +```sh +make build +make test +make run +make test-s3 +``` - - - +`make test-s3` is a manual S3/Litestream smoke test. Set `LITESTREAM_TEMPLATE=s3` and override the S3 values from `.env.dist` in `.env` before running it. ------ +## Maintenance -Consider to [support](https://github.com/sponsors/f3l1x) **f3l1x**. Also thank you for using this package. +See [how to contribute](https://github.com/dockette/.github/blob/master/CONTRIBUTING.md) to this package. Consider to [support](https://github.com/sponsors/f3l1x) **f3l1x**. Thank you for using this package.