Skip to content

Commit 7cd349c

Browse files
authored
Merge pull request #2 from CodeShellDev/migrate/golang
migrate: to golang
2 parents fe79005 + f8d21e2 commit 7cd349c

File tree

22 files changed

+1067
-266
lines changed

22 files changed

+1067
-266
lines changed

.dockerignore

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
1-
!app.py
1+
# env file
2+
*.env
3+
4+
# Exclude git folders
5+
.git*
6+
!.github
7+
8+
# Ignore yml files
9+
*.yaml
10+
*.yml
11+
12+
# Markdown files
13+
*.md
14+
15+
# Include data/
16+
!data/*
Lines changed: 66 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,113 @@
1+
<div align="center">
2+
<a href="https://github.com/codeshelldev/servdiscovery/releases">
3+
<img
4+
src="https://img.shields.io/github/v/release/codeshelldev/servdiscovery?sort=semver&logo=github&label=Release"
5+
alt="GitHub release"
6+
>
7+
</a>
8+
<a href="https://github.com/codeshelldev/servdiscovery/stargazers">
9+
<img
10+
src="https://img.shields.io/github/stars/codeshelldev/servdiscovery?style=flat&logo=github&label=Stars"
11+
alt="GitHub stars"
12+
>
13+
</a>
14+
<a href="https://github.com/codeshelldev/servdiscovery/pkgs/container/servdiscovery">
15+
<img
16+
src="https://ghcr-badge.egpl.dev/codeshelldev/servdiscovery/size?color=%2344cc11&tag=latest&label=Image+Size&trim="
17+
alt="Docker image size"
18+
>
19+
</a>
20+
<a href="https://github.com/codeshelldev/servdiscovery/pkgs/container/servdiscovery">
21+
<img
22+
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"
23+
alt="Docker image Pulls"
24+
>
25+
</a>
26+
<a href="./LICENSE">
27+
<img
28+
src="https://img.shields.io/badge/License-MIT-green.svg"
29+
alt="License: MIT"
30+
>
31+
</a>
32+
</div>
33+
134
# ServDiscovery
235

3-
ServDiscovery is a Discovery Service that keeps an Endpoint updated with active Hosts (of Services).
36+
**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.
437

538
## Installation
639

7-
> [!NOTE]
8-
> ServDiscovery only works with Traefik and not with **any** other Reverse Proxy due to `traefik.http.routers.router.rule` label
40+
> [!IMPORTANT]
41+
> ServDiscovery works **only with Traefik**. It will **not** work with other reverse proxies due to using traefik labels to determine routes.
942
10-
Get the latest `docker-compose.yaml` file:
43+
Get the latest `docker-compose.yaml`:
1144

1245
```yaml
1346
{{{ #://docker-compose.yaml }}}
1447
```
1548

49+
Then spin it up:
50+
1651
```bash
1752
docker compose up -d
1853
```
1954

55+
Your discovery service is now live! 🎉
56+
2057
## Usage
2158

22-
Take this little `whoami` Container as an Example:
59+
Let's take a simple `whoami` container as an example:
2360

2461
```yaml
2562
{{{ #://examples/whoami.docker-compose.yaml }}}
2663
```
2764

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

31-
## Endpoint
68+
## Endpoint Integration
3269

33-
ServDiscovery sends requests to the Endpoint as a **JSON HTTP Request**:
70+
ServDiscovery communicates with your endpoint via **JSON HTTP Requests**:
3471

3572
```json
3673
{{{ #://examples/payload.json }}}
3774
```
3875

39-
This example tell the Endpoint that...
76+
Example explanation:
4077

41-
| Available | Unavailable |
78+
| Available | ❌ Unavailable |
4279
| -------------------- | --------------------------- |
4380
| whoami.mydomain.com | whoami-backup.mydomain.com |
4481
| website.mydomain.com | website-backup.mydomain.com |
4582
| auth.mydomain.com | auth-backup.mydomain.com |
4683

47-
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,
48-
thus updating the list of routable Containers / Services.
84+
This allows the endpoint (e.g., a load balancer) to remove `\*-backup` records from your registry and **update routable containers/services automatically**.
85+
86+
### Integrations
87+
88+
You can find example integrations inside of [examples/](./examples).
4989

5090
## Configuration
5191

52-
### ENDPOINT_KEY
92+
### `ENDPOINT_KEY`
93+
94+
The endpoint key is used in the `Authorization` header (Bearer token) when ServDiscovery sends POST requests.
95+
If no key is provided, the header is omitted.
96+
97+
### `DISCOVERY_INTERVAL`
5398

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

57-
### DISCOVERY_INTERVAL
102+
### `ALIVE_INTERVAL`
58103

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

61107
## Contributing
62108

63-
Found a bug or have new ideas or enhancements for this Project?
64-
Feel free to open up an issue or create a Pull Request!
109+
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.
65110

66111
## License
67112

68-
[MIT](https://choosealicense.com/licenses/mit/)
113+
This project is licensed under the [MIT License](./LICENSE).

.github/workflows/docker-image-dev.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ on:
44
push:
55
branches:
66
- dev
7-
paths-ignore:
8-
- ".**"
7+
paths:
8+
- "**/*.go"
99

1010
jobs:
1111
update:
12-
uses: codeshelldev/gh-actions/.github/workflows/docker-image.yml@main
12+
uses: codeshelldev/gh-actions/.github/workflows/docker-image-go.yml@main
13+
name: Development Image
1314
with:
1415
registry: ghcr.io
1516
flavor: |

.github/workflows/docker-image.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ on:
66

77
jobs:
88
update:
9-
uses: codeshelldev/gh-actions/.github/workflows/docker-image.yml@main
9+
uses: codeshelldev/gh-actions/.github/workflows/docker-image-go.yml@main
10+
name: Stable Image
1011
with:
1112
registry: ghcr.io
1213
secrets:

.github/workflows/readme-update.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ on:
1010
jobs:
1111
update:
1212
uses: codeshelldev/gh-actions/.github/workflows/readme-update.yml@main
13+
name: Update
1314
secrets:
1415
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,33 @@
1-
.env
2-
.venv
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
8+
# Test binary, built with `go test -c`
9+
*.test
10+
11+
# Code coverage profiles and other test artifacts
12+
*.out
13+
coverage.*
14+
*.coverprofile
15+
profile.cov
16+
17+
# Dependency directories (remove the comment below to include it)
18+
# vendor/
19+
20+
# Go workspace file
21+
go.work
22+
go.work.sum
23+
24+
# env file
25+
*.env
26+
27+
# Editor/IDE
28+
# .idea/
29+
.vscode/
30+
31+
# Exclude git folders
32+
.git*
33+
!.github

Dockerfile

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
FROM python:3.12-alpine
1+
FROM alpine:3.22
2+
RUN apk --no-cache add ca-certificates
23

3-
WORKDIR /app
4+
ARG IMAGE_TAG
5+
ENV IMAGE_TAG=$IMAGE_TAG
6+
LABEL org.opencontainers.image.version=$IMAGE_TAG
7+
8+
ARG TARGETOS
9+
ARG TARGETARCH
410

5-
RUN pip install docker
11+
WORKDIR /app
612

713
COPY . .
814

9-
ENV PORT=4531
15+
COPY dist/${TARGETOS}/${TARGETARCH}/app .
1016

11-
EXPOSE ${PORT}
17+
RUN rm dist/ -r
1218

13-
CMD ["python", "app.py"]
19+
CMD ["./app"]

0 commit comments

Comments
 (0)