Skip to content

Commit

Permalink
Merge branch 'devel' into monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
HilkopterBob authored Oct 29, 2024
2 parents 167a0b3 + 7705541 commit 3a7decc
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 34 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/nightly_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Nightly Release

on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 1.0.0)'
required: true

jobs:
release:
name: Create Nightly Release
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v3


- name: Set APP_VERSION
id: version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
VERSION=${{ github.event.inputs.version }}
else
VERSION=${{ github.ref }}
VERSION=${VERSION#refs/tags/}
fi
echo "APP_VERSION=$VERSION" >> $GITHUB_ENV
- name: Build Go Application
run: |
mkdir -p ${{ github.workspace }}/packagelock
APP_VERSION=${{ env.APP_VERSION }}
CGO_ENABLED=0 GOOS=linux go build -ldflags "-X 'main.AppVersion=$APP_VERSION'" -o ${{ github.workspace }}/packagelock
- name: Create Release Archive
run: |
mkdir -p release
cp -r ${{ github.workspace }}/packagelock ./release/packagelock
tar -czvf release/packagelock-${{ env.APP_VERSION }}-linux-amd64-nightly.tar.gz -C release packagelock
- name: Calculate Checksum
run: |
md5sum ./release/packagelock-${{ env.APP_VERSION }}-linux-amd64-nightly.tar.gz | cut -f 1 -d " " > ./release/packagelock-${{ env.APP_VERSION }}-linux-amd64.tar.gz.md5
- name: Upload Release Tarball
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: https://api.github.com/repos/HilkopterBob/PackageLock/releases/180504390/assets
asset_path: ./release/packagelock-${{ env.APP_VERSION }}-linux-amd64-nightly.tar.gz
asset_name: packagelock-${{ env.APP_VERSION }}-linux-amd64-nightly.tar.gz
asset_content_type: application/gzip

- name: Upload Checksum
id: upload-checksum-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: https://api.github.com/repos/HilkopterBob/PackageLock/releases/180504390/assets
asset_path: ./release/packagelock-${{ env.APP_VERSION }}-linux-amd64-nightly.tar.gz.md5
asset_name: packagelock-${{ env.APP_VERSION }}-linux-amd64-nightly.tar.gz.md5
asset_content_type: text/plain
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/HilkopterBob/PackageLock/.github%2Fworkflows%2Frun-tests.yml)
![GitHub Actions Workflow Status](https://github.com/hilkopterbob/packagelock/actions/workflows/test-build.yml/badge.svg)
![GitHub Actions Workflow Status](https://github.com/hilkopterbob/packagelock/actions/workflows/release_tag.yml/badge.svg)
![GitHub Actions Workflow Status](https://github.com/hilkopterbob/packagelock/actions/workflows/golangci-lint.yml/badge.svg)
![GitHub Actions Workflow Status](https://github.com/hilkopterbob/packagelock/actions/workflows/build-docker-container.yml/badge.svg)
![GitHub Actions Workflow Status](https://github.com/hilkopterbob/packagelock/actions/workflows/unstable-build-docker-container.yml/badge.svg)
Expand Down
22 changes: 22 additions & 0 deletions server/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
jwtware "github.com/gofiber/contrib/jwt"
"github.com/gofiber/contrib/otelfiber"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/healthcheck"
"github.com/gofiber/fiber/v2/middleware/monitor"
"github.com/gofiber/fiber/v2/middleware/recover"
"github.com/gofiber/template/html/v2"
"github.com/golang-jwt/jwt/v5"
Expand Down Expand Up @@ -49,6 +51,12 @@ func NewServer(params ServerParams) *fiber.App {
params.Logger.Info("Added OpenTelemetry Middleware.")
}

// Middleware for simple resource Monitor
// only use in Non-Production mode
if !params.Config.GetBool("general.production") {
app.Get("/monitor", monitor.New(monitor.Config{Title: "PackageLock Dev Monitoring Page"}))
}

// Middleware for logging
app.Use(fiberzap.New(fiberzap.Config{
Logger: params.Logger,
Expand All @@ -73,6 +81,20 @@ func NewServer(params ServerParams) *fiber.App {
app.Use(prometheus.Middleware)
params.Logger.Info("Added Monitoring Middleware.")
}

// Middleware for healthcheck
app.Use(healthcheck.New(healthcheck.Config{
LivenessProbe: func(c *fiber.Ctx) bool {
return true
},
LivenessEndpoint: "/livez",

ReadinessProbe: func(c *fiber.Ctx) bool {
return true
},
ReadinessEndpoint: "/readyz",
}))
params.Logger.Info("Added HealtCheck Middleware.")

// Add routes
addRoutes(app, params)
Expand Down
2 changes: 1 addition & 1 deletion templates/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

<div class="center-box" id="box">
<h1>404 - Page not found 😢</h1>
<p>Read the <a href="https://github.com/HilkopterBob/PackageLock" target="_blank">PackageLock Docs! 🚀</a></p>
<p>Read the <a href="https://github.com/HilkopterBob/PackageLock" target="_blank" rel="noopener">PackageLock Docs! 🚀</a></p>
<p>{{ .AppVersion }}</p>
</div>

Expand Down
16 changes: 9 additions & 7 deletions wiki/_Sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
- Hosts
- [Get Host][hosts]
- [Register Host][hosts_reg]
- [Dev-Home][dev-home]

[home]: Home
[apidocs]: API-Docs
[auth_login]:login
[agents]:get_agent_by_id
[agents_reg]:register_agent
[general_agents]:get_agents
[general_hosts]:get_hosts
[hosts]:get_host_by_agentid
[hosts_reg]:register_host
[auth_login]: login
[agents]: get_agent_by_id
[agents_reg]: register_agent
[general_agents]: get_agents
[general_hosts]: get_hosts
[hosts]: get_host_by_agentid
[hosts_reg]: register_host
[dev-home]: dev-home
30 changes: 17 additions & 13 deletions wiki/developer docs/Dev-Home.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
# PackageLock Developer Documentation


Welcome to the official developer documentation for **PackageLock**! This wiki serves as a comprehensive resource for developers looking to understand, contribute to, and extend the project.

## Table of Contents

- [Getting Started](#getting-started)
- [Architecture Overview](#architecture-overview)
- [API Reference](#api-reference)
- [Contributing](#contributing)
- [FAQ](#faq)
- [Support](#support)
- [Getting Started][getting-started]
- [Architecture Overview][architecture-overview]
- [API Reference][api-reference]
- [Contributing][contributing]
- [FAQ][faq]
- [Support][support]

## Getting Started

Begin your journey by following the [Getting Started](./Getting-Started.md) guide. This section will help you set up the development environment, install dependencies, and run the project locally.
Begin your journey by following the [Getting Started][getting-started] guide. This section will help you set up the development environment, install dependencies, and run the project locally.

## Architecture Overview

Understand the core architecture of **PackageLock** in the [Architecture Overview](./Architecture-Overview.md) section. Learn about the main components, their interactions, and the design principles that guide the project.
Understand the core architecture of **PackageLock** in the [Architecture Overview][architecture-overview] section. Learn about the main components, their interactions, and the design principles that guide the project.

## Contributing

We welcome contributions from the community! Please read our [Contributing](./Contributing.md) guidelines to learn how you can help improve **PackageLock**. This includes information on coding standards, submitting issues, and making pull requests.
We welcome contributions from the community! Please read our [Contributing][contributing] guidelines to learn how you can help improve **PackageLock**. This includes information on coding standards, submitting issues, and making pull requests.

## FAQ

Have questions? Check out our [FAQ](./FAQ.md) for answers to common questions.
Have questions? Check out our [FAQ][faq] for answers to common questions.

---

*Happy Coding! 🚀*

_Happy Coding! 🚀_

[getting-started]: getting-started
[architecture-overview]: architecture-overview
[api-reference]: api-reference
[contributing]: contributing
[faq]: faq
[support]: support
16 changes: 4 additions & 12 deletions wiki/developer docs/_Sidebar.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
# Navigation

- [Home][home]
- [Dev-Home][dev-home]
- [Getting Started][getting-started]
- [Contributing][contributing]
- [FAQ][faq]

[home]: Home

- Dev-Home

[dev-home]: Dev-Home

- Getting Started

[getting-started]: Getting-Started

- Contributing

[contributing]: Contributing

- FAQ

[faq]: FAQ

0 comments on commit 3a7decc

Please sign in to comment.