chore: add more building tools and scripts

This commit is contained in:
Tommy 2024-09-09 21:25:18 +02:00
parent fe510445c8
commit a87bc989fd
Signed by: tommy
SSH key fingerprint: SHA256:1LWgQT3QPHIT29plS8jjXc3S1FcE/4oGvsx3Efxs6Uc
6 changed files with 139 additions and 8 deletions

13
.taskfiles/docker.yaml Normal file
View file

@ -0,0 +1,13 @@
version: "3"
tasks:
create-image:
desc: Build local docker image (am-ntfy-builder)
dir: "docker"
cmds:
- docker build --platform linux/amd64 -t am-ntfy-builder --no-cache .
shell:
desc: Drop into a build shell
cmds:
- docker run -v /var/run/docker.sock:/var/run/docker.sock -v ./:/root/working-dir -w /root/working-dir --platform linux/amd64 -it am-ntfy-builder -c "fish"

View file

@ -8,14 +8,13 @@ send them to [ntfy](https://ntfy.sh/) push notifications
Configuration is done with environment variables.
| Variable | Description | Example |
|---------------|------------------------------|------------------------|
| HTTP_ADDRESS | Adress to listen on | `localhost` |
| HTTP_PORT | Port to listen on | `8080` |
| NTFY_TOPIC | ntfy topic to send to | `https://ntfy.sh/test` |
| NTFY_USER | ntfy user for basic auth | `myuser` |
| NTFY_PASS | ntfy password for basic auth | `supersecret` |
| NTFY_PRIORITY | Priority of ntfy messages | `high` |
| Variable | Description | Example |
|-----------------|------------------------------|-------------------|
| HTTP_ADDRESS | Adress to listen on | `localhost` |
| HTTP_PORT | Port to listen on | `8080` |
| NTFY_SERVER_URL | ntfy server to send to | `https://ntfy.sh` |
| NTFY_USER | ntfy user for basic auth | `myuser` |
| NTFY_PASS | ntfy password for basic auth | `supersecret` |
# Nix
@ -28,6 +27,12 @@ privides app to test the hooks with mocked data from `mock.json`
nix build .#container
```
### Push to registry
```sh
nix run .#push-container
```
### Run directly
```sh

14
Taskfile.yaml Normal file
View file

@ -0,0 +1,14 @@
version: "3"
vars:
PROJECT_DIR:
sh: "git rev-parse --show-toplevel"
includes:
docker: .taskfiles/docker.yaml
tasks:
default:
silent: true
cmds:
- task -l

35
docker/Dockerfile Normal file
View file

@ -0,0 +1,35 @@
# Use the nixpkgs/nix image
# https://github.com/NixOS/nix/tags
FROM nixos/nix:2.23.3
# Set the working directory
WORKDIR /root/working-dir
ARG MAIN_NIX_CHANNEL=https://nixos.org/channels/nixos-24.05
ARG MAIN_NIX_CHANNEL_NAME=nixpkgs
ENV NIXPKGS_ALLOW_UNFREE=1
# Set environment variables
ENV NIX_PATH=nixpkgs=channel:nixos-24.05
ARG NIX_CONFIG=
ADD nix.conf /etc/nix/nix.conf
RUN echo $'\n'"${NIX_CONFIG}" >> /etc/nix/nix.conf
RUN mkdir -p "/root" && touch "/root/.nix-channels" && \
if [[ ! -f "/root/.nix-profile" ]]; then ln -sf /nix/var/nix/profiles/default "/root/.nix-profile"; fi && \
. /nix/var/nix/profiles/default/etc/profile.d/nix.sh && \
nix-channel --add ${MAIN_NIX_CHANNEL} ${MAIN_NIX_CHANNEL_NAME} && \
nix-channel --update
RUN chown $USER_UID:$USER_GID /nix \
&& chown $USER_UID:$USER_GID /nix/store \
&& chown -R $USER_UID:$USER_GID /nix/var
RUN bash -c "nix-env -iA nixpkgs.go nixpkgs.vim nixpkgs.sops nixpkgs.nix-direnv nixpkgs.attic-client nixpkgs.nh nixpkgs.deploy-rs nixpkgs.statix nixpkgs.deadnix nixpkgs.alejandra nixpkgs.git nixpkgs.ssh-to-age nixpkgs.gnupg nixpkgs.age nixpkgs.linux nixpkgs.go-task nixpkgs.curl nixpkgs.fish nixpkgs.docker"
ENTRYPOINT ["fish"]
# Start bash shell
CMD [ "-c", "nix develop" ]

6
docker/nix.conf Normal file
View file

@ -0,0 +1,6 @@
filter-syscalls = false
experimental-features = nix-command flakes
extra-platforms = x86_64-linux aarch64-linux
build-users-group = nixbld
trusted-users = root @admin @wheel vscode
system-features = kvm big-parallel

58
examples/prometheus.json Normal file
View file

@ -0,0 +1,58 @@
{
"alerts": [
{
"annotations": {
"grafana": "http://grafana.example.com/dashboard/db/overview?var-service=test-service&var-project=test-project",
"summary": "Error on a.example"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "http://prometheus.example",
"labels": {
"alertname": "test-alert",
"instance": "a.example",
"project": "test-project",
"service": "test-service",
"severity": "major"
},
"startsAt": "2017-10-06T16:21:28.214665326+09:00",
"fingerprint": "77219b85044057b4",
"status": "firing"
},
{
"annotations": {
"grafana": "http://grafana.example.com/dashboard/db/overview?var-service=test-service&var-project=test-project",
"summary": "Error on b.example"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "http://prometheus.example",
"labels": {
"alertname": "test-alert",
"instance": "b.example",
"project": "test-project",
"service": "test-service",
"severity": "major"
},
"startsAt": "2017-10-06T16:21:28.214665326+09:00",
"fingerprint": "77219b85044057b3",
"status": "firing"
}
],
"commonAnnotations": {
"grafana": "http://grafana.example.com/dashboard/db/overview?var-service=test-service&var-project=test-project"
},
"commonLabels": {
"alertname": "test-alert",
"project": "test-project",
"service": "test-service",
"severity": "major"
},
"externalURL": "http://alertmanager.example",
"groupKey": "{}:{project=\"test-project\", service=\"test-service\"}",
"groupLabels": {
"project": "test-project",
"service": "test-service"
},
"receiver": "default",
"status": "firing",
"version": "4"
}