Skip to content

Commit defc07c

Browse files
authored
refactor: move dashboard out of separate package (#24)
* refactor: move dashboard out of separate package * feat: add option to disable dashboard * chore: update dockerfile and compose * docs: update readme * chore: update release workflows
1 parent ea6d714 commit defc07c

24 files changed

Lines changed: 252 additions & 635 deletions

.github/workflows/release.yml

Lines changed: 11 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
id: meta
1717
uses: docker/metadata-action@v6
1818
with:
19-
images: ghcr.io/${{ github.repository_owner }}/tinyauth-analytics
19+
images: ghcr.io/${{ github.repository_owner }}/analytics
2020

2121
- name: Login to GitHub Container Registry
2222
uses: docker/login-action@v3
@@ -34,7 +34,7 @@ jobs:
3434
with:
3535
platforms: linux/amd64
3636
labels: ${{ steps.meta.outputs.labels }}
37-
tags: ghcr.io/${{ github.repository_owner }}/tinyauth-analytics
37+
tags: ghcr.io/${{ github.repository_owner }}/analytics
3838
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
3939
build-args: |
4040
VERSION=${{ github.ref_name }}
@@ -53,54 +53,6 @@ jobs:
5353
if-no-files-found: error
5454
retention-days: 1
5555

56-
image-build-dashboard:
57-
runs-on: ubuntu-latest
58-
steps:
59-
- name: Checkout
60-
uses: actions/checkout@v6
61-
62-
- name: Docker meta
63-
id: meta
64-
uses: docker/metadata-action@v6
65-
with:
66-
images: ghcr.io/${{ github.repository_owner }}/tinyauth-analytics-dashboard
67-
68-
- name: Login to GitHub Container Registry
69-
uses: docker/login-action@v3
70-
with:
71-
registry: ghcr.io
72-
username: ${{ github.repository_owner }}
73-
password: ${{ secrets.GITHUB_TOKEN }}
74-
75-
- name: Set up Docker Buildx
76-
uses: docker/setup-buildx-action@v4
77-
78-
- name: Build and push
79-
uses: docker/build-push-action@v7
80-
id: build
81-
with:
82-
platforms: linux/amd64
83-
labels: ${{ steps.meta.outputs.labels }}
84-
tags: ghcr.io/${{ github.repository_owner }}/tinyauth-analytics-dashboard
85-
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
86-
context: ./dashboard
87-
build-args: |
88-
VERSION=${{ github.ref_name }}
89-
90-
- name: Export digest
91-
run: |
92-
mkdir -p ${{ runner.temp }}/digests
93-
digest="${{ steps.build.outputs.digest }}"
94-
touch "${{ runner.temp }}/digests/${digest#sha256:}"
95-
96-
- name: Upload digest
97-
uses: actions/upload-artifact@v7
98-
with:
99-
name: dashboard-digests-linux-amd64
100-
path: ${{ runner.temp }}/digests/*
101-
if-no-files-found: error
102-
retention-days: 1
103-
10456
image-build-arm:
10557
runs-on: ubuntu-24.04-arm
10658
steps:
@@ -111,7 +63,7 @@ jobs:
11163
id: meta
11264
uses: docker/metadata-action@v6
11365
with:
114-
images: ghcr.io/${{ github.repository_owner }}/tinyauth-analytics
66+
images: ghcr.io/${{ github.repository_owner }}/analytics
11567

11668
- name: Login to GitHub Container Registry
11769
uses: docker/login-action@v3
@@ -129,7 +81,7 @@ jobs:
12981
with:
13082
platforms: linux/arm64
13183
labels: ${{ steps.meta.outputs.labels }}
132-
tags: ghcr.io/${{ github.repository_owner }}/tinyauth-analytics
84+
tags: ghcr.io/${{ github.repository_owner }}/analytics
13385
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
13486
build-args: |
13587
VERSION=${{ github.ref_name }}
@@ -148,54 +100,6 @@ jobs:
148100
if-no-files-found: error
149101
retention-days: 1
150102

151-
image-build-arm-dashboard:
152-
runs-on: ubuntu-24.04-arm
153-
steps:
154-
- name: Checkout
155-
uses: actions/checkout@v6
156-
157-
- name: Docker meta
158-
id: meta
159-
uses: docker/metadata-action@v6
160-
with:
161-
images: ghcr.io/${{ github.repository_owner }}/tinyauth-analytics-dashboard
162-
163-
- name: Login to GitHub Container Registry
164-
uses: docker/login-action@v3
165-
with:
166-
registry: ghcr.io
167-
username: ${{ github.repository_owner }}
168-
password: ${{ secrets.GITHUB_TOKEN }}
169-
170-
- name: Set up Docker Buildx
171-
uses: docker/setup-buildx-action@v4
172-
173-
- name: Build and push
174-
uses: docker/build-push-action@v7
175-
id: build
176-
with:
177-
platforms: linux/arm64
178-
labels: ${{ steps.meta.outputs.labels }}
179-
tags: ghcr.io/${{ github.repository_owner }}/tinyauth-analytics-dashboard
180-
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
181-
context: ./dashboard
182-
build-args: |
183-
VERSION=${{ github.ref_name }}
184-
185-
- name: Export digest
186-
run: |
187-
mkdir -p ${{ runner.temp }}/digests
188-
digest="${{ steps.build.outputs.digest }}"
189-
touch "${{ runner.temp }}/digests/${digest#sha256:}"
190-
191-
- name: Upload digest
192-
uses: actions/upload-artifact@v7
193-
with:
194-
name: dashboard-digests-linux-arm64
195-
path: ${{ runner.temp }}/digests/*
196-
if-no-files-found: error
197-
retention-days: 1
198-
199103
image-merge:
200104
runs-on: ubuntu-latest
201105
needs:
@@ -223,53 +127,16 @@ jobs:
223127
id: meta
224128
uses: docker/metadata-action@v6
225129
with:
226-
images: ghcr.io/${{ github.repository_owner }}/tinyauth-analytics
227-
tags: |
228-
type=semver,pattern={{version}},prefix=v
229-
type=semver,pattern={{major}},prefix=v
230-
type=semver,pattern={{major}}.{{minor}},prefix=v
231-
232-
- name: Create manifest list and push
233-
working-directory: ${{ runner.temp }}/digests
234-
run: |
235-
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
236-
$(printf 'ghcr.io/${{ github.repository_owner }}/tinyauth-analytics@sha256:%s ' *)
237-
238-
image-merge-dashboard:
239-
runs-on: ubuntu-latest
240-
needs:
241-
- image-build-dashboard
242-
- image-build-arm-dashboard
243-
steps:
244-
- name: Download digests
245-
uses: actions/download-artifact@v4
246-
with:
247-
path: ${{ runner.temp }}/digests
248-
pattern: dashboard-digests-*
249-
merge-multiple: true
250-
251-
- name: Login to GitHub Container Registry
252-
uses: docker/login-action@v3
253-
with:
254-
registry: ghcr.io
255-
username: ${{ github.repository_owner }}
256-
password: ${{ secrets.GITHUB_TOKEN }}
257-
258-
- name: Set up Docker Buildx
259-
uses: docker/setup-buildx-action@v4
260-
261-
- name: Docker meta
262-
id: meta
263-
uses: docker/metadata-action@v6
264-
with:
265-
images: ghcr.io/${{ github.repository_owner }}/tinyauth-analytics-dashboard
130+
images: ghcr.io/${{ github.repository_owner }}/analytics
131+
flavor: |
132+
prefix=v,onlatest=false
266133
tags: |
267-
type=semver,pattern={{version}},prefix=v
268-
type=semver,pattern={{major}},prefix=v
269-
type=semver,pattern={{major}}.{{minor}},prefix=v
134+
type=semver,pattern={{version}}
135+
type=semver,pattern={{major}}
136+
type=semver,pattern={{major}}.{{minor}}
270137
271138
- name: Create manifest list and push
272139
working-directory: ${{ runner.temp }}/digests
273140
run: |
274141
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
275-
$(printf 'ghcr.io/${{ github.repository_owner }}/tinyauth-analytics-dashboard@sha256:%s ' *)
142+
$(printf 'ghcr.io/${{ github.repository_owner }}/analytics@sha256:%s ' *)

.gitignore

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
# data
2-
data
3-
41
# debug
52
__debug_*
63

74
# build out
8-
tinyauth-analytics
5+
/analytics
96

10-
# benchmarks
11-
bench
7+
# data
8+
/analytics.db*
9+
/data

.vscode/launch.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ COPY go.sum ./
1111
RUN go mod download
1212

1313
COPY ./cache.go ./
14+
COPY ./dashboard.html ./
15+
COPY ./dashboard_handler.go ./
16+
COPY ./favicon.ico ./
1417
COPY ./health_handler.go ./
1518
COPY ./instances_handler.go ./
1619
COPY ./main.go ./
1720
COPY ./rate_limiter.go ./
18-
COPY ./database ./database
21+
COPY ./queries ./queries
1922

2023
RUN CGO_ENABLED=0 go build -o analytics -ldflags "-s -w -X main.version=${VERSION}"
2124

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2025 steveiliop56
1+
Copyright 2026 steveiliop56
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
44

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
A simple server to transparently collect version information from Tinyauth instances.
44

5-
## How does it work
5+
## How it works
66

7-
Every Tinyauth instance runs a goroutine (unless you choose to opt-out) that does a "heartbeat" every 12 hours indicating the instance is still alive. The heartbeat contains the UUID generated by Tinyauth on start up and the version information. The server stores them in the SQLite database alongside with the last seen date. When you request all the instances, the server responds with an array containing the versions, UUIDs and last seen dates.
7+
Every Tinyauth instance runs a goroutine (unless you choose to opt-out) that does a "heartbeat" every 12 hours indicating the instance is still "alive". The heartbeat contains the UUID generated by Tinyauth on start up and the version information. The server stores them in the SQLite database alongside with the last seen date. When you request all the instances, the server responds with an array containing the versions, UUIDs and last seen dates.
88

99
## Running
1010

11-
The central information server is hosted at `https://api.tinyauth.app` and all instance information can be requested from the `/v1/instances/all` endpoint. But, if you like, you can run your own server for your own projects, you can do so by simply cloning the repository and running:
11+
The central information server is hosted at `https://api.tinyauth.app` and all instance information can be requested from the `/v1/instances/all` endpoint or be seen visually on the `/dashboard` page. If you like, you can run your own server for your own projects. This can be done by cloning the repository and running:
1212

1313
```sh
1414
docker compose up -d
@@ -26,11 +26,12 @@ The server is configured using environment variables, the following options are
2626
| `RATE_LIMIT_COUNT` | number | Maximum number of requests per minute per IP. | `3` |
2727
| `CORS_ALLOWED_ORIGINS` | string/array | Comma-separated list of allowed CORS origins. | `*` |
2828
| `TRUSTED_PROXIES` | string/array | Comma-separated list of trusted proxy IPs. | `` |
29+
| `DASHBOARD_ENABLED` | boolean | Whether to enable the dashboard. | `true` |
2930

3031
## Contributing
3132

3233
If you like you can contribute to this project by picking up an [issue](https://github.com/tinyauthapp/analytics/issues) or creating a [pull request](https://github.com/tinyauthapp/analytics/pulls). Contributing is appreciated a lot!
3334

3435
## License
3536

36-
Tinyauth analytics is licensed under the MIT License. TL;DR — You can use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software. Just make sure to include the original license in any substantial portions of the code. There’s no warranty — use at your own risk. See the [LICENSE](./LICENSE) file for full details.
37+
Tinyauth analytics is licensed under the MIT License. TL;DR — You can use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software. Just make sure to include the original license in any substantial portions of the code. There’s no warranty — use at your own risk. See the [LICENSE](LICENSE) file for full details.

0 commit comments

Comments
 (0)