Skip to content

Commit b98f608

Browse files
committed
ci: move gen doc to dedicated CI && improve docs
1 parent 2c78634 commit b98f608

File tree

17 files changed

+351
-129
lines changed

17 files changed

+351
-129
lines changed

.github/workflows/documentation.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: github page
2+
3+
on:
4+
workflow_dispatch:
5+
repository_dispatch:
6+
types: [update-doc]
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
documentation:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Configure Git Credentials
17+
run: |
18+
git config user.name github-actions[bot]
19+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
20+
- uses: actions/setup-python@v4
21+
with:
22+
python-version: 3.x
23+
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
24+
- uses: actions/cache@v3
25+
with:
26+
key: mkdocs-material-${{ env.cache_id }}
27+
path: .cache
28+
restore-keys: |
29+
mkdocs-material-
30+
- run: pip install mkdocs-material pymdown-extensions
31+
- run: mkdocs gh-deploy --force

.github/workflows/release.yaml

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,7 @@ jobs:
3838
args: release --clean -f .goreleaser.yaml
3939
env:
4040
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41-
42-
documentation:
43-
runs-on: ubuntu-latest
44-
needs: release-app
45-
steps:
46-
- uses: actions/checkout@v4
47-
- name: Configure Git Credentials
48-
run: |
49-
git config user.name github-actions[bot]
50-
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
51-
- uses: actions/setup-python@v4
52-
with:
53-
python-version: 3.x
54-
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
55-
- uses: actions/cache@v3
41+
- name: Repository Dispatch
42+
uses: peter-evans/repository-dispatch@v2
5643
with:
57-
key: mkdocs-material-${{ env.cache_id }}
58-
path: .cache
59-
restore-keys: |
60-
mkdocs-material-
61-
- run: pip install mkdocs-material pymdown-extensions
62-
- run: mkdocs gh-deploy --force
44+
event-type: update-doc

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ FROM alpine
1313
ENV GID 1000
1414
ENV UID 1000
1515

16+
RUN apk add curl
17+
1618
COPY --from=ui-build-stage --chown=${UID}:${GID} /app/dist /www/
1719
COPY --from=ui-build-stage --chown=${UID}:${GID} /app/src/assets/images /www/assets/images
1820
COPY golink /

docs/configuration/env-vars.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
hide:
3+
- toc
4+
---
5+
6+
# Environment variables
7+
8+
| Environment Variable | Default | Description |
9+
| --- | --- | --- |
10+
| `GOLINK_SERVER_HOST` | localhost | The host address for the Golink server. |
11+
| `GOLINK_SERVER_PORT` | 8081 | The port number for the Golink server. |
12+
| `GOLINK_SERVER_URL` | <http://localhost:8081> | The URL for the Golink server. |
13+
| `GOLINK_HEALTH_SERVER_HOST` | localhost | The host address for the Golink health server. |
14+
| `GOLINK_HEALTH_SERVER_PORT` | 8082 | The port number for the Golink health server. |

docs/configuration/file.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
hide:
3+
- toc
4+
---
5+
6+
# Configuration file
7+
8+
!!! warning "Under development"
9+
GoLink is under development and the configuration file is not yet implemented for the moment.

docs/deployment/docker-compose.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
hide:
3+
- toc
4+
---
5+
6+
# Docker Compose
7+
8+
Docker Compose is a tool for defining and running multi-container Docker applications. It is a good choice for small deployments.
9+
10+
## How to run
11+
12+
1. Install Docker Compose. See the [Docker Compose installation instructions](https://docs.docker.com/compose/install/).
13+
2. Create a file named `docker-compose.yml` with the following content:
14+
15+
```yaml
16+
version: '3.7'
17+
18+
services:
19+
golink:
20+
image: ghcr.io/azrod/golink:latest
21+
container_name: golink
22+
restart: unless-stopped
23+
healthcheck:
24+
test: ["CMD", "curl -f http://localhost:8082 || exit 1"]
25+
timeout: 30s
26+
interval: 1m
27+
retries: 3
28+
ports:
29+
- "127.0.0.1:8081:8081"
30+
```
31+
32+
3. Run the Golink server:
33+
34+
```bash
35+
docker compose up -d
36+
```

docs/deployment/getting-start.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,28 @@ hide:
66
# Deployment
77

88
* [Docker](docker.md)
9-
* Docker Compose (coming soon)
9+
* [Docker Compose](docker-compose.md)
1010
* Kubernetes (coming soon)
1111
* Helm (coming soon)
1212
* [Manual](manual.md)
13+
14+
## How to run
15+
16+
1. Choose a deployment method.
17+
2. Follow the instructions for installing glctl.
18+
3. Use glctl to add a link:
19+
20+
```bash
21+
glctl --host localhost:8081 add link MyApp /myapp https://myapp.example.com
22+
```
23+
24+
4. Open the golink web ui in a browser:
25+
26+
<http://localhost:8081/u/>
27+
28+
5. Follow the link to MyApp:
29+
30+
<http://localhost:8081/myapp>
31+
32+
!!! note "Note"
33+
Replace `localhost:8081` with the host and port for your Golink server.

docs/deployment/manual.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
hide:
3+
- toc
4+
---
5+
6+
# Manual deployment
7+
8+
Manual deployment is a basic deployment method that is suitable for small deployments. It is also useful for testing and development.
9+
The binaries for the Golink server are available on the [releases page](https://github.com/azrod/golink/releases/latest).
10+
11+
## How to run
12+
13+
1. Download the binary for your platform from the [releases page](https://github.com/azrod/golink/releases/latest).
14+
2. Run the binary:
15+
16+
```bash
17+
./golink
18+
```

docs/glctl/usage.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
hide:
3+
- toc
4+
---
5+
6+
# How to use
7+
8+
```bash
9+
glctl is a CLI for golink. It allows you to manage golink from the command line.
10+
11+
Usage:
12+
glctl [command]
13+
14+
GoLink Commands
15+
add Add commands
16+
delete Delete commands
17+
get Get commands
18+
19+
Other Commands
20+
version Returns the version of the application
21+
22+
Additional Commands:
23+
completion Generate the autocompletion script for the specified shell
24+
help Help about any command
25+
26+
Flags:
27+
--config string config file (default is $HOME/.golink/config.yaml)
28+
--debug debug mode
29+
-h, --help help for glctl
30+
--host string golink host (default "http://localhost:8081")
31+
-n, --namespace string namespace (default "default")
32+
-o, --output string output format (default "short")
33+
--timeout int timeout in seconds (default 10)
34+
35+
Use "glctl [command] --help" for more information about a command.
36+
```
37+
38+
## How to configure
39+
40+
`glctl` uses a configuration file looking for `$HOME/.golink/config.yaml` by default.
41+
You can specify a different configuration file with the `--config` flag.
42+
43+
If you don't have a configuration file, it will be created automatically when you run the `glctl` command for the first time.
44+
45+
**Default configuration file:**
46+
47+
```{ .yaml .copy }
48+
debug: false
49+
host: http://localhost:8081
50+
namespace: default
51+
timeout: 10
52+
```

docs/storage/index.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
hide:
3+
- toc
4+
---
5+
6+
# Storage backend
7+
8+
!!! note "Note"
9+
The golink server has a pluggable storage backend. Actually, only one storage backend is implemented at the moment, but the plan is to add more in the future.
10+
11+
## List of storage backends
12+
13+
* [Redis](redis.md)

docs/storage/redis.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
hide:
3+
- toc
4+
---
5+
6+
# Redis storage backend
7+
8+
Use Redis as the storage backend for Golink. Golink persists the data in Redis, so that it can be used across multiple instances of the Golink server.
9+
10+
## Configuration
11+
12+
The Redis storage backend is configured using environment variables. The following environment variables are available:
13+
14+
| Environment Variable | Default | Description |
15+
| --- | --- | --- |
16+
| `GOLINK_SB_REDIS_ADDRESS` | `localhost:6379` | The address of the Redis server. |
17+
| `GOLINK_SB_REDIS_USERNAME` | _None_ | The username for the Redis server. |
18+
| `GOLINK_SB_REDIS_PASSWORD` | _None_ | The password for the Redis server. |
19+
| `GOLINK_SB_REDIS_DB` | `0` | The Redis database number. |
20+
| `GOLINK_SB_REDIS_MAX_RETRIES` | `3` | The maximum number of retries when connecting to the Redis server. |
21+
| `GOLINK_SB_REDIS_DIAL_TIMEOUT` | `5` | The timeout in seconds for connecting to the Redis server. |
22+
| `GOLINK_SB_REDIS_READ_TIMEOUT` | `3` | The timeout in seconds for reading from the Redis server. |
23+
| `GOLINK_SB_REDIS_WRITE_TIMEOUT` | `3` | The timeout in seconds for writing to the Redis server. |
24+
| `GOLINK_SB_REDIS_CERT_FILE` | _None_ | The path to the certificate file for the Redis server. |
25+
| `GOLINK_SB_REDIS_KEY_FILE` | _None_ | The path to the key file for the Redis server. |
26+
| `GOLINK_SB_REDIS_CA_FILE` | _None_ | The path to the CA file for the Redis server. |
27+
28+
## Example
29+
30+
To use Redis as the storage backend for Golink, you can run a Redis server in a Docker container and then run the Golink server in a Docker container. The following example shows how to do this.
31+
32+
1. Create a directory for the Redis server:
33+
34+
```bash
35+
mkdir -p ~/redis/data
36+
```
37+
38+
2. Create a file named `docker-compose.yml` with the following content:
39+
40+
```yaml
41+
version: '3.7'
42+
43+
services:
44+
redis:
45+
image: redis:latest
46+
container_name: redis
47+
volumes:
48+
- ~/redis/data:/data
49+
golink:
50+
image: ghcr.io/azrod/golink:latest
51+
container_name: golink
52+
environment:
53+
GOLINK_SB_REDIS_ADDRESS=redis:6379
54+
ports:
55+
- "8081:8081"
56+
```
57+
58+
3. Run the Redis and Golink server:
59+
60+
```bash
61+
docker-compose up -d
62+
```
63+
64+
4. Use glctl to add a golink:
65+
66+
```bash
67+
glctl --host localhost:8081 add link MyApp /myapp https://myapp.example.com
68+
```
69+
70+
5. Open the golink web ui in a browser:
71+
72+
<http://localhost:8081/u/>
73+
74+
6. Follow the link to MyApp:
75+
76+
<http://localhost:8081/myapp>

docs/stylesheets/extra.css

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* [data-md-color-scheme="golink"] { */
21
:root {
32
--md-primary-bg-color: rgb(203, 166, 247);
43

@@ -21,9 +20,9 @@
2120
--md-code-bg-color: rgb(17, 17, 27);
2221
--md-code-fg-color: rgb(137, 220, 235);
2322
--md-code-hl-punctuation-color: rgb(137, 220, 235);
24-
/*
23+
2524
--md-default-fg-color--lightest: rgb(250, 179, 135);
26-
--md-accent-fg-color: rgb(243, 139, 168); */
25+
--md-accent-fg-color: rgb(243, 139, 168);
2726
}
2827

2928
.md-header__button.md-logo {

go.work

Lines changed: 0 additions & 3 deletions
This file was deleted.

go.work.sum

Lines changed: 0 additions & 29 deletions
This file was deleted.

main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ func main() {
4343

4444
cfg := config{}
4545

46-
if err := envconfig.Process(ctx, &cfg); err != nil {
46+
l := envconfig.PrefixLookuper("GOLINK_", envconfig.OsLookuper())
47+
if err := envconfig.ProcessWith(ctx, &cfg, l); err != nil {
4748
panic(err)
4849
}
4950

50-
db, err := clients.NewClient(ctx, clients.Settings{})
51+
db, err := clients.NewClient(ctx, clients.Settings{}, l)
5152
if err != nil {
5253
panic(err)
5354
}

0 commit comments

Comments
 (0)