Compare commits

..

No commits in common. "77d1cfbc81c7bac8599ac226e3429011f5cf3885" and "ae7439d3aed979c66d16c2c546c48cf4e0a3abbb" have entirely different histories.

12 changed files with 76 additions and 258 deletions

View file

@ -1,37 +1,54 @@
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@v4
with:
fetch-depth: 0
uses: actions/checkout@v2
- 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:
@ -42,13 +59,18 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: Build artifacts
run: devbox run -- just unstable
- name: Build binaries
run: devbox run -- just build-bin
- uses: actions/upload-artifact@v4
- name: Build and push
uses: docker/build-push-action@v5
with:
name: Unstable Build
path: dist
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 }}
deploy:
runs-on: ubuntu-latest
@ -57,7 +79,7 @@ jobs:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v2
- name: Install devbox
uses: jetify-com/devbox-install-action@v0.11.0
with:

View file

@ -1,46 +0,0 @@
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
View file

@ -1,5 +1,4 @@
bin/
dist/
# Node
node_modules/

View file

@ -48,10 +48,10 @@ just generate-jwt-key
# Start development environment
just run
# Or build binaries, packages, docker images...
just build
# Or build only one binary.
just build-only-binary
# Or build binaries
just build-bin
# Or docker image (for current platform)
just build-docker
```
### License

View file

@ -1,6 +1,9 @@
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
@ -19,5 +22,8 @@ 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"]

View file

@ -1,26 +1,22 @@
# Only build binary for current platform.
build-only-bin:
goreleaser build --snapshot --clean --single-target --config ./build/release.yaml
# Build the application
build: build-bin build-docker
# 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}
# 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
done
docker manifest create {{ DOCKER_IMAGE }} ${IMAGES}
docker manifest push {{ DOCKER_IMAGE }}
# Stable release process.
release:
goreleaser release --clean --config ./build/release.yaml
# Build docker image
build-docker: build-bin
#!/bin/bash
docker buildx build \
-f build/Dockerfile \
-t {{DOCKER_IMAGE}} \
.

View file

@ -1,100 +0,0 @@
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"

View file

@ -14,12 +14,6 @@ import (
"github.com/mentos1386/zdravko/pkg/worker"
)
var (
version = "dev"
commit = "none"
date = "unknown"
)
type StartableAndStoppable interface {
Name() string
Start() error
@ -48,8 +42,7 @@ func main() {
flag.BoolVar(&startTemporal, "temporal", false, "Start the temporal")
flag.Parse()
slog.Info("Starting zdravko", "version", version, "commit", commit, "date", date)
slog.Info("Components...", "server", startServer, "worker", startWorker, "temporal", startTemporal)
slog.Info("Starting zdravko...", "server", startServer, "worker", startWorker, "temporal", startTemporal)
if !startServer && !startWorker && !startTemporal {
slog.Error("At least one of the following must be set: --server, --worker, --temporal")

View file

@ -12,5 +12,5 @@ deploy-fly-set-jwt-key-secrets:
EOF
# Deploy locally with docker compose
deploy-docker: build
deploy-docker: build-docker
docker compose --file dpeloy/docker-compose.yaml up

View file

@ -8,7 +8,6 @@
"sqlite-web@latest",
"go@1.22",
"tailwindcss@latest",
"temporal-cli@latest",
"goreleaser@latest"
"temporal-cli@latest"
]
}

View file

@ -69,54 +69,6 @@
}
}
},
"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",

View file

@ -8,9 +8,6 @@ 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"
@ -55,7 +52,7 @@ generate-jwt-key:
openssl rsa -pubout -in jwt.private.pem -out jwt.public.pem
# Run Docker application.
run-docker: build
run-docker: build-docker
docker run -p 8080:8080 \
-it --rm \
-e SESSION_SECRET \