Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
7977daf
Merge pull request #1 from CodeShellDev/main
CodeShellDev Aug 23, 2025
385e4bd
fixed containers not being global
CodeShellDev Aug 23, 2025
15385a9
fixed typo
CodeShellDev Aug 23, 2025
2b99b2d
fixed misunderstanding of count()
CodeShellDev Aug 23, 2025
ecf05d5
fixed unset variables
CodeShellDev Aug 23, 2025
04d574f
fixed loop exiting to soon
CodeShellDev Aug 23, 2025
01865b4
debugging
CodeShellDev Aug 23, 2025
69bf9bc
fix newly added containers not contributing to global diff
CodeShellDev Aug 23, 2025
9476e64
further debug
CodeShellDev Aug 23, 2025
cd14c5e
revert
CodeShellDev Aug 23, 2025
a93f67a
fixed wrong json key
CodeShellDev Aug 23, 2025
2511caa
added Full Discoveries to give the endpoint a complete Update
CodeShellDev Aug 30, 2025
0eaa243
Update README.md
github-actions[bot] Aug 30, 2025
82700f3
fix typo in README
CodeShellDev Aug 30, 2025
81f8e48
Update README.md
github-actions[bot] Aug 30, 2025
575c3b4
convert to int
CodeShellDev Aug 30, 2025
23eb46b
round to int
CodeShellDev Aug 30, 2025
070f1b0
moved i to the top of the func
CodeShellDev Aug 30, 2025
21ac2bf
Update app.py
CodeShellDev Oct 6, 2025
9f42269
initial port
CodeShellDev Dec 5, 2025
b45e72d
Update README.md
github-actions[bot] Dec 5, 2025
29bf913
readme update
CodeShellDev Dec 5, 2025
d33b09c
Merge branch 'migrate/golang' of https://github.com/CodeShellDev/serv…
CodeShellDev Dec 5, 2025
e537c54
Update README.md
github-actions[bot] Dec 5, 2025
cb19623
fix readme
CodeShellDev Dec 5, 2025
56ee774
Merge branch 'migrate/golang' of https://github.com/CodeShellDev/serv…
CodeShellDev Dec 5, 2025
5b55dfb
Update README.md
github-actions[bot] Dec 5, 2025
b194a90
fix readme
CodeShellDev Dec 5, 2025
a7ce158
Merge branch 'migrate/golang' of https://github.com/CodeShellDev/serv…
CodeShellDev Dec 5, 2025
bf5e362
Update README.md
github-actions[bot] Dec 5, 2025
9293c1b
fix typo
CodeShellDev Dec 5, 2025
fde4236
Merge branch 'migrate/golang' of https://github.com/CodeShellDev/serv…
CodeShellDev Dec 5, 2025
c61f5f1
Update README.md
github-actions[bot] Dec 5, 2025
b6cdd50
update Dockerfile
CodeShellDev Dec 5, 2025
a3c59c1
update workflows
CodeShellDev Dec 5, 2025
032e200
update deps
CodeShellDev Dec 5, 2025
3e8e30c
pin alpine due to buildx issue
CodeShellDev Dec 5, 2025
63be50c
fix docker compose
CodeShellDev Dec 5, 2025
12e3928
Update README.md
github-actions[bot] Dec 5, 2025
deb2231
add log for docker image
CodeShellDev Dec 5, 2025
710a6cc
init docker socket client
CodeShellDev Dec 5, 2025
b10fae9
fix readme
CodeShellDev Dec 5, 2025
6407d47
Update README.md
github-actions[bot] Dec 5, 2025
ac2e113
rearrange logs
CodeShellDev Dec 5, 2025
1930946
initialize hostmap
CodeShellDev Dec 5, 2025
e847372
hide logs when no changes
CodeShellDev Dec 5, 2025
e4c0ffc
debug
CodeShellDev Dec 5, 2025
11c52a9
dont print diff if empty
CodeShellDev Dec 5, 2025
1f0f397
cleanup
CodeShellDev Dec 5, 2025
d05208b
more debugging
CodeShellDev Dec 5, 2025
da7c143
fix host matching
CodeShellDev Dec 5, 2025
55fe6a9
debugging
CodeShellDev Dec 5, 2025
aef37fc
add name
CodeShellDev Dec 5, 2025
29aa32a
actually add hosts for discoveries
CodeShellDev Dec 5, 2025
49a100b
use map
CodeShellDev Dec 5, 2025
16bf813
fix bearer auth
CodeShellDev Dec 5, 2025
b015b00
show if auth or not instead of leaking token
CodeShellDev Dec 5, 2025
38c0b8e
remove devlogs
CodeShellDev Dec 5, 2025
f8d21e2
Merge branch 'main' into migrate/golang
CodeShellDev Dec 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
!app.py
# env file
*.env

# Exclude git folders
.git*
!.github

# Ignore yml files
*.yaml
*.yml

# Markdown files
*.md

# Include data/
!data/*
87 changes: 66 additions & 21 deletions .github/templates/README.template.md
Original file line number Diff line number Diff line change
@@ -1,68 +1,113 @@
<div align="center">
<a href="https://github.com/codeshelldev/servdiscovery/releases">
<img
src="https://img.shields.io/github/v/release/codeshelldev/servdiscovery?sort=semver&logo=github&label=Release"
alt="GitHub release"
>
</a>
<a href="https://github.com/codeshelldev/servdiscovery/stargazers">
<img
src="https://img.shields.io/github/stars/codeshelldev/servdiscovery?style=flat&logo=github&label=Stars"
alt="GitHub stars"
>
</a>
<a href="https://github.com/codeshelldev/servdiscovery/pkgs/container/servdiscovery">
<img
src="https://ghcr-badge.egpl.dev/codeshelldev/servdiscovery/size?color=%2344cc11&tag=latest&label=Image+Size&trim="
alt="Docker image size"
>
</a>
<a href="https://github.com/codeshelldev/servdiscovery/pkgs/container/servdiscovery">
<img
src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fghcr-badge.elias.eu.org%2Fapi%2Fcodeshelldev%2Fservdiscovery%2Fservdiscovery&query=downloadCount&label=Downloads&color=2344cc11"
alt="Docker image Pulls"
>
</a>
<a href="./LICENSE">
<img
src="https://img.shields.io/badge/License-MIT-green.svg"
alt="License: MIT"
>
</a>
</div>

# ServDiscovery

ServDiscovery is a Discovery Service that keeps an Endpoint updated with active Hosts (of Services).
**ServDiscovery** is a dynamic **Discovery Service** that keeps your endpoints in sync with active hosts of your services — perfect for modern, containerized environments. Think of it as the bridge between your services and your reverse proxy, ensuring traffic always finds the right destination.

## Installation

> [!NOTE]
> ServDiscovery only works with Traefik and not with **any** other Reverse Proxy due to `traefik.http.routers.router.rule` label
> [!IMPORTANT]
> ServDiscovery works **only with Traefik**. It will **not** work with other reverse proxies due to using traefik labels to determine routes.

Get the latest `docker-compose.yaml` file:
Get the latest `docker-compose.yaml`:

```yaml
{{{ #://docker-compose.yaml }}}
```

Then spin it up:

```bash
docker compose up -d
```

Your discovery service is now live! 🎉

## Usage

Take this little `whoami` Container as an Example:
Let's take a simple `whoami` container as an example:

```yaml
{{{ #://examples/whoami.docker-compose.yaml }}}
```

Whenever a new **Host-Rule** gets added / modified ServDiscovery will update the set Endpoint to notify of any new changes.
This way the Endpoint can correctly route to different Hosts based on **SNI / Hostnames**.
Whenever a new **Host-Rule** is added or updated, ServDiscovery will **automatically notify the configured endpoint**.
This ensures the endpoint can correctly route traffic based on **SNI / Hostnames**.

## Endpoint
## Endpoint Integration

ServDiscovery sends requests to the Endpoint as a **JSON HTTP Request**:
ServDiscovery communicates with your endpoint via **JSON HTTP Requests**:

```json
{{{ #://examples/payload.json }}}
```

This example tell the Endpoint that...
Example explanation:

| Available | Unavailable |
| Available | ❌ Unavailable |
| -------------------- | --------------------------- |
| whoami.mydomain.com | whoami-backup.mydomain.com |
| website.mydomain.com | website-backup.mydomain.com |
| auth.mydomain.com | auth-backup.mydomain.com |

This way (if the Endpoint is used by a LoadBalancer) the Owner of the Endpoint can now delete the `*-backup.mydomain.com` records from a Registry,
thus updating the list of routable Containers / Services.
This allows the endpoint (e.g., a load balancer) to remove `\*-backup` records from your registry and **update routable containers/services automatically**.

### Integrations

You can find example integrations inside of [examples/](./examples).

## Configuration

### ENDPOINT_KEY
### `ENDPOINT_KEY`

The endpoint key is used in the `Authorization` header (Bearer token) when ServDiscovery sends POST requests.
If no key is provided, the header is omitted.

### `DISCOVERY_INTERVAL`

The Endpoint Key is provided in the Authorization Header (via Bearer) during the POST request between the Endpoint and ServDiscovery.
If no Key is provided ServDiscovery will leave out the Authorization Header.
Time (in seconds) between updates to your endpoint.
**Default:** `60` seconds

### DISCOVERY_INTERVAL
### `ALIVE_INTERVAL`

The Discovery Interval sets the Interval of which ServDiscovery will update the Endpoint, etc.
Time (in seconds) between full alive discoveries. ServDiscovery sends a **complete update** of all active containers in the `added` JSON key.
**Default:** `120` seconds

## Contributing

Found a bug or have new ideas or enhancements for this Project?
Feel free to open up an issue or create a Pull Request!
Found a bug or have a brilliant idea? Contributions are welcome! Open an **issue** or create a **pull request** — your help makes this project better.

## License

[MIT](https://choosealicense.com/licenses/mit/)
This project is licensed under the [MIT License](./LICENSE).
7 changes: 4 additions & 3 deletions .github/workflows/docker-image-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ on:
push:
branches:
- dev
paths-ignore:
- ".**"
paths:
- "**/*.go"

jobs:
update:
uses: codeshelldev/gh-actions/.github/workflows/docker-image.yml@main
uses: codeshelldev/gh-actions/.github/workflows/docker-image-go.yml@main
name: Development Image
with:
registry: ghcr.io
flavor: |
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ on:

jobs:
update:
uses: codeshelldev/gh-actions/.github/workflows/docker-image.yml@main
uses: codeshelldev/gh-actions/.github/workflows/docker-image-go.yml@main
name: Stable Image
with:
registry: ghcr.io
secrets:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/readme-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ on:
jobs:
update:
uses: codeshelldev/gh-actions/.github/workflows/readme-update.yml@main
name: Update
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35 changes: 33 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,33 @@
.env
.venv
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Code coverage profiles and other test artifacts
*.out
coverage.*
*.coverprofile
profile.cov

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work
go.work.sum

# env file
*.env

# Editor/IDE
# .idea/
.vscode/

# Exclude git folders
.git*
!.github
18 changes: 12 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
FROM python:3.12-alpine
FROM alpine:3.22
RUN apk --no-cache add ca-certificates

WORKDIR /app
ARG IMAGE_TAG
ENV IMAGE_TAG=$IMAGE_TAG
LABEL org.opencontainers.image.version=$IMAGE_TAG

ARG TARGETOS
ARG TARGETARCH

RUN pip install docker
WORKDIR /app

COPY . .

ENV PORT=4531
COPY dist/${TARGETOS}/${TARGETARCH}/app .

EXPOSE ${PORT}
RUN rm dist/ -r

CMD ["python", "app.py"]
CMD ["./app"]
Loading