mirror of
https://github.com/mentos1386/zdravko.git
synced 2024-11-25 08:58:50 +00:00
Compare commits
4 commits
ae7439d3ae
...
77d1cfbc81
Author | SHA1 | Date | |
---|---|---|---|
77d1cfbc81 | |||
1d106b1c40 | |||
fa418b839d | |||
ee92c2d19b |
12 changed files with 258 additions and 76 deletions
62
.github/workflows/build.yaml
vendored
62
.github/workflows/build.yaml
vendored
|
@ -1,54 +1,37 @@
|
|||
name: Build
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 10 * * *"
|
||||
push:
|
||||
branches:
|
||||
- "main"
|
||||
tags:
|
||||
- "v*.*.*"
|
||||
pull_request:
|
||||
branches:
|
||||
- "main"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
attestations: write
|
||||
id-token: write
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Install devbox
|
||||
uses: jetify-com/devbox-install-action@v0.11.0
|
||||
with:
|
||||
enable-cache: true
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
ghcr.io/mentos1386/zdravko
|
||||
tags: |
|
||||
type=schedule
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
type=sha
|
||||
|
||||
- name: Setup Golang cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
|
@ -59,18 +42,13 @@ jobs:
|
|||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
|
||||
- name: Build binaries
|
||||
run: devbox run -- just build-bin
|
||||
- name: Build artifacts
|
||||
run: devbox run -- just unstable
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
file: build/Dockerfile
|
||||
context: .
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
name: Unstable Build
|
||||
path: dist
|
||||
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
@ -79,7 +57,7 @@ jobs:
|
|||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
- name: Install devbox
|
||||
uses: jetify-com/devbox-install-action@v0.11.0
|
||||
with:
|
||||
|
|
46
.github/workflows/release.yaml
vendored
Normal file
46
.github/workflows/release.yaml
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
attestations: write
|
||||
id-token: write
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Install devbox
|
||||
uses: jetify-com/devbox-install-action@v0.11.0
|
||||
with:
|
||||
enable-cache: true
|
||||
- name: Setup Golang cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cache/go-build
|
||||
~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
|
||||
- name: Release
|
||||
run: devbox run -- just release
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
bin/
|
||||
dist/
|
||||
|
||||
# Node
|
||||
node_modules/
|
||||
|
|
|
@ -48,10 +48,10 @@ just generate-jwt-key
|
|||
# Start development environment
|
||||
just run
|
||||
|
||||
# Or build binaries
|
||||
just build-bin
|
||||
# Or docker image (for current platform)
|
||||
just build-docker
|
||||
# Or build binaries, packages, docker images...
|
||||
just build
|
||||
# Or build only one binary.
|
||||
just build-only-binary
|
||||
```
|
||||
|
||||
### License
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
FROM gcr.io/distroless/static-debian12:latest as production
|
||||
ARG TARGETARCH
|
||||
ARG TARGETOS
|
||||
|
||||
COPY ./bin/zdravko-${TARGETOS}-${TARGETARCH} /bin/zdravko
|
||||
|
||||
COPY zdravko /bin/zdravko
|
||||
COPY LICENSE /LICENSE
|
||||
COPY README.md /README.md
|
||||
|
||||
|
@ -22,8 +19,5 @@ ENV TEMPORAL_DATABASE_PATH=/data/temporal.db
|
|||
ENV KEYVALUE_DATABASE_PATH=/data/keyvalue.db
|
||||
VOLUME /data
|
||||
|
||||
ENV DATABASE_PATH=/data/zdravko.db
|
||||
ENV TEMPORAL_DATABASE_PATH=/data/temporal.db
|
||||
|
||||
ENTRYPOINT ["/bin/zdravko"]
|
||||
CMD ["--server", "--temporal", "--worker"]
|
||||
|
|
|
@ -1,22 +1,26 @@
|
|||
# Build the application
|
||||
build: build-bin build-docker
|
||||
# Only build binary for current platform.
|
||||
build-only-bin:
|
||||
goreleaser build --snapshot --clean --single-target --config ./build/release.yaml
|
||||
|
||||
# Build multiarch binaries
|
||||
build-bin:
|
||||
#!/bin/bash
|
||||
for os in {{OS}}
|
||||
do
|
||||
for arch in {{ARCH}}
|
||||
do
|
||||
echo "Building zdravko for $os $arch..."
|
||||
CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -o bin/zdravko-$os-$arch cmd/zdravko/main.go
|
||||
done
|
||||
# Build binaries, packages, docker images for all platforms.
|
||||
build:
|
||||
goreleaser release --snapshot --clean --config ./build/release.yaml
|
||||
|
||||
# Unstable release process.
|
||||
unstable:
|
||||
#!/bin/env bash
|
||||
set -exuo pipefail
|
||||
goreleaser release --clean --snapshot --config ./build/release.yaml
|
||||
|
||||
IMAGES=$(docker image ls --format "{{'{{ .Repository }}:{{ .Tag }}'}}" | grep -e "{{ DOCKER_IMAGE }}.*")
|
||||
|
||||
for image in ${IMAGES}; do
|
||||
docker push ${image}
|
||||
done
|
||||
|
||||
# Build docker image
|
||||
build-docker: build-bin
|
||||
#!/bin/bash
|
||||
docker buildx build \
|
||||
-f build/Dockerfile \
|
||||
-t {{DOCKER_IMAGE}} \
|
||||
.
|
||||
docker manifest create {{ DOCKER_IMAGE }} ${IMAGES}
|
||||
docker manifest push {{ DOCKER_IMAGE }}
|
||||
|
||||
# Stable release process.
|
||||
release:
|
||||
goreleaser release --clean --config ./build/release.yaml
|
||||
|
|
100
build/release.yaml
Normal file
100
build/release.yaml
Normal file
|
@ -0,0 +1,100 @@
|
|||
report_sizes: true
|
||||
|
||||
changelog:
|
||||
use: github
|
||||
|
||||
snapshot:
|
||||
name_template: "{{ .Version }}-UNSTABLE-{{ .ShortCommit }}"
|
||||
|
||||
builds:
|
||||
- main: ./cmd/zdravko
|
||||
mod_timestamp: "{{ .CommitTimestamp }}"
|
||||
flags:
|
||||
- -trimpath
|
||||
goos:
|
||||
- "darwin"
|
||||
- "freebsd"
|
||||
- "linux"
|
||||
- "windows"
|
||||
goarch:
|
||||
- "amd64"
|
||||
- "arm64"
|
||||
|
||||
nfpms:
|
||||
- vendor: Tine Jozelj
|
||||
homepage: https://zdravko.mnts.dev
|
||||
maintainer: Tine Jozelj <me@mnts.dev>
|
||||
license: AGPL-3.0
|
||||
description: |
|
||||
Zdravko is a selfhosted healthcheck service designed to work for small scale,
|
||||
or multi region deployments. It can monitor virtually anything.
|
||||
formats:
|
||||
- apk
|
||||
- deb
|
||||
- rpm
|
||||
- termux.deb
|
||||
- archlinux
|
||||
provides:
|
||||
- zdravko
|
||||
|
||||
universal_binaries:
|
||||
- replace: true
|
||||
|
||||
archives:
|
||||
- format: tar.gz
|
||||
wrap_in_directory: true
|
||||
format_overrides:
|
||||
- goos: windows
|
||||
format: zip
|
||||
|
||||
dockers:
|
||||
- image_templates:
|
||||
- "{{ .Env.DOCKER_REGISTRY }}:sha-{{ .ShortCommit }}-amd64"
|
||||
- "{{ .Env.DOCKER_REGISTRY }}:{{ .Version }}-amd64"
|
||||
- "{{ .Env.DOCKER_REGISTRY }}:latest-amd64"
|
||||
use: buildx
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
dockerfile: build/Dockerfile
|
||||
extra_files:
|
||||
- "README.md"
|
||||
- "LICENSE"
|
||||
build_flag_templates:
|
||||
- "--pull"
|
||||
- "--label=org.opencontainers.image.created={{.Date}}"
|
||||
- "--label=org.opencontainers.image.title={{.ProjectName}}"
|
||||
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
|
||||
- "--label=org.opencontainers.image.version={{.Version}}"
|
||||
- "--platform=linux/amd64"
|
||||
- image_templates:
|
||||
- "{{ .Env.DOCKER_REGISTRY }}:sha-{{ .ShortCommit }}-arm64"
|
||||
- "{{ .Env.DOCKER_REGISTRY }}:{{ .Version }}-arm64"
|
||||
- "{{ .Env.DOCKER_REGISTRY }}:latest-arm64"
|
||||
use: buildx
|
||||
goos: linux
|
||||
goarch: arm64
|
||||
dockerfile: build/Dockerfile
|
||||
extra_files:
|
||||
- "README.md"
|
||||
- "LICENSE"
|
||||
build_flag_templates:
|
||||
- "--pull"
|
||||
- "--label=org.opencontainers.image.created={{.Date}}"
|
||||
- "--label=org.opencontainers.image.title={{.ProjectName}}"
|
||||
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
|
||||
- "--label=org.opencontainers.image.version={{.Version}}"
|
||||
- "--platform=linux/arm64"
|
||||
|
||||
docker_manifests:
|
||||
- name_template: "{{ .Env.DOCKER_REGISTRY }}:sha-{{ .ShortCommit }}"
|
||||
image_templates:
|
||||
- "{{ .Env.DOCKER_REGISTRY }}:{{ .Version }}-amd64"
|
||||
- "{{ .Env.DOCKER_REGISTRY }}:{{ .Version }}-arm64"
|
||||
- name_template: "{{ .Env.DOCKER_REGISTRY }}:{{ .Version }}"
|
||||
image_templates:
|
||||
- "{{ .Env.DOCKER_REGISTRY }}:{{ .Version }}-amd64"
|
||||
- "{{ .Env.DOCKER_REGISTRY }}:{{ .Version }}-arm64"
|
||||
- name_template: "{{ .Env.DOCKER_REGISTRY }}:latest"
|
||||
image_templates:
|
||||
- "{{ .Env.DOCKER_REGISTRY }}:{{ .Version }}-amd64"
|
||||
- "{{ .Env.DOCKER_REGISTRY }}:{{ .Version }}-arm64"
|
|
@ -14,6 +14,12 @@ import (
|
|||
"github.com/mentos1386/zdravko/pkg/worker"
|
||||
)
|
||||
|
||||
var (
|
||||
version = "dev"
|
||||
commit = "none"
|
||||
date = "unknown"
|
||||
)
|
||||
|
||||
type StartableAndStoppable interface {
|
||||
Name() string
|
||||
Start() error
|
||||
|
@ -42,7 +48,8 @@ func main() {
|
|||
flag.BoolVar(&startTemporal, "temporal", false, "Start the temporal")
|
||||
flag.Parse()
|
||||
|
||||
slog.Info("Starting zdravko...", "server", startServer, "worker", startWorker, "temporal", startTemporal)
|
||||
slog.Info("Starting zdravko", "version", version, "commit", commit, "date", date)
|
||||
slog.Info("Components...", "server", startServer, "worker", startWorker, "temporal", startTemporal)
|
||||
|
||||
if !startServer && !startWorker && !startTemporal {
|
||||
slog.Error("At least one of the following must be set: --server, --worker, --temporal")
|
||||
|
|
|
@ -12,5 +12,5 @@ deploy-fly-set-jwt-key-secrets:
|
|||
EOF
|
||||
|
||||
# Deploy locally with docker compose
|
||||
deploy-docker: build-docker
|
||||
deploy-docker: build
|
||||
docker compose --file dpeloy/docker-compose.yaml up
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
"sqlite-web@latest",
|
||||
"go@1.22",
|
||||
"tailwindcss@latest",
|
||||
"temporal-cli@latest"
|
||||
"temporal-cli@latest",
|
||||
"goreleaser@latest"
|
||||
]
|
||||
}
|
||||
|
|
48
devbox.lock
48
devbox.lock
|
@ -69,6 +69,54 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"goreleaser@latest": {
|
||||
"last_modified": "2024-05-29T10:04:41Z",
|
||||
"resolved": "github:NixOS/nixpkgs/ac82a513e55582291805d6f09d35b6d8b60637a1#goreleaser",
|
||||
"source": "devbox-search",
|
||||
"version": "1.26.2",
|
||||
"systems": {
|
||||
"aarch64-darwin": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/3igms7180pkaki16zvfid4q7jp2g22b0-goreleaser-1.26.2",
|
||||
"default": true
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/3igms7180pkaki16zvfid4q7jp2g22b0-goreleaser-1.26.2"
|
||||
},
|
||||
"aarch64-linux": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/k5cnmyfha51wygjalza3kf6kjwwds0lh-goreleaser-1.26.2",
|
||||
"default": true
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/k5cnmyfha51wygjalza3kf6kjwwds0lh-goreleaser-1.26.2"
|
||||
},
|
||||
"x86_64-darwin": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/9xx7jd8hi5ff305kysnq7wylf92w69vh-goreleaser-1.26.2",
|
||||
"default": true
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/9xx7jd8hi5ff305kysnq7wylf92w69vh-goreleaser-1.26.2"
|
||||
},
|
||||
"x86_64-linux": {
|
||||
"outputs": [
|
||||
{
|
||||
"name": "out",
|
||||
"path": "/nix/store/lwgrhyjg21q6zd1akid2v1nxxnpsscz1-goreleaser-1.26.2",
|
||||
"default": true
|
||||
}
|
||||
],
|
||||
"store_path": "/nix/store/lwgrhyjg21q6zd1akid2v1nxxnpsscz1-goreleaser-1.26.2"
|
||||
}
|
||||
}
|
||||
},
|
||||
"just@latest": {
|
||||
"last_modified": "2024-01-27T14:55:31Z",
|
||||
"resolved": "github:NixOS/nixpkgs/160b762eda6d139ac10ae081f8f78d640dd523eb#just",
|
||||
|
|
5
justfile
5
justfile
|
@ -8,6 +8,9 @@ export JWT_PRIVATE_KEY := `cat jwt.private.pem || echo ""`
|
|||
export JWT_PUBLIC_KEY := `cat jwt.public.pem || echo ""`
|
||||
|
||||
GIT_SHA := `git rev-parse --short HEAD`
|
||||
|
||||
export DOCKER_REGISTRY := "ghcr.io/mentos1386/zdravko"
|
||||
|
||||
DOCKER_IMAGE := "ghcr.io/mentos1386/zdravko:sha-"+GIT_SHA
|
||||
|
||||
STATIC_DIR := "./web/static"
|
||||
|
@ -52,7 +55,7 @@ generate-jwt-key:
|
|||
openssl rsa -pubout -in jwt.private.pem -out jwt.public.pem
|
||||
|
||||
# Run Docker application.
|
||||
run-docker: build-docker
|
||||
run-docker: build
|
||||
docker run -p 8080:8080 \
|
||||
-it --rm \
|
||||
-e SESSION_SECRET \
|
||||
|
|
Loading…
Reference in a new issue