Skip to content

Commit e758db4

Browse files
authored
docs: use proper documentation infra (#858)
1 parent 72863f5 commit e758db4

File tree

13 files changed

+1755
-332
lines changed

13 files changed

+1755
-332
lines changed

.github/workflows/docs-test.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
permissions: {}
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
tests:
17+
permissions:
18+
contents: read # clone the repository
19+
checks: write # write CI checkmarks
20+
pull-requests: write # write/comment on PRs
21+
security-events: write # write new SARIF events
22+
uses: grafana/writers-toolkit/.github/workflows/docs-ci.yml@main
23+
with:
24+
build: true
25+
build-website-directory: content/docs/grafana-image-renderer
26+
prettier: true
27+
vale: true
28+
# Doesn't yet work on forks.
29+
readability: false

.gitignore

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,5 @@
1-
lib-cov
2-
*.seed
3-
*.log
4-
*.dat
5-
*.out
6-
*.pid
7-
*.gz
8-
*.swp
9-
10-
pids
11-
logs
12-
results
13-
tmp
14-
151
# Build
162
dist
17-
build
18-
artifacts
19-
20-
# Dependency directory
21-
node_modules
22-
bower_components
233

244
# Editors
255
.idea
@@ -30,19 +10,5 @@ bower_components
3010
.DS_Store
3111
Thumbs.db
3212

33-
# Ignore built ts files
34-
dist/**/*
35-
36-
# Ignore output from coverage report
37-
coverage
38-
39-
scripts/tmp
40-
41-
tests/testdata/diff_*
42-
43-
cache
44-
45-
/devenv/docker/tracing/tempo-data/
46-
4713
# Grafana Enterprise licence keys
4814
*.jwt

.vale.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
MinAlertLevel = warning
2+
3+
[*.md]
4+
BasedOnStyles = Grafana
5+
TokenIgnores = (<http[^\n]+>+?), \*\*[^\n]+\*\*

Makefile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
OUT_DIR = dist
2+
BINARY ?= $(OUT_DIR)/grafana-image-renderer
3+
4+
.PHONY: check
5+
check: lint test
6+
7+
.PHONY: test
8+
test:
9+
go test ./... -timeout=60s
10+
11+
.PHONY: test-acceptance
12+
test-acceptance:
13+
docker build -t gir .
14+
IMAGE=gir go test ./tests/acceptance/... -timeout=60s
15+
16+
.PHONY: lint
17+
lint:
18+
go tool goimports -l .
19+
golangci-lint run
20+
21+
.PHONY: fix
22+
fix:
23+
go tool goimports -w .
24+
golangci-lint run --fix
25+
26+
.PHONY: build
27+
build: $(OUT_DIR)
28+
go build -buildvcs -o $(BINARY) .
29+
30+
.PHONY: build-all
31+
build-all: build $(OUT_DIR)
32+
GOOS=linux GOARCH=amd64 go build -buildvcs -o $(OUT_DIR)/grafana-image-renderer-linux-amd64 .
33+
GOOS=linux GOARCH=arm64 go build -buildvcs -o $(OUT_DIR)/grafana-image-renderer-linux-arm64 .
34+
GOOS=darwin GOARCH=amd64 go build -buildvcs -o $(OUT_DIR)/grafana-image-renderer-darwin-amd64 .
35+
GOOS=darwin GOARCH=arm64 go build -buildvcs -o $(OUT_DIR)/grafana-image-renderer-darwin-arm64 .
36+
GOOS=windows GOARCH=amd64 go build -buildvcs -o $(OUT_DIR)/grafana-image-renderer-windows-amd64.exe .
37+
GOOS=windows GOARCH=arm64 go build -buildvcs -o $(OUT_DIR)/grafana-image-renderer-windows-arm64.exe .
38+
39+
.PHONY: clean
40+
clean:
41+
rm -rf "$(OUT_DIR)"
42+
43+
.PHONY: docs-dev
44+
docs-dev:
45+
make -C docs docs
46+
47+
.PHONY: docs
48+
docs:
49+
make -C docs update vale
50+
51+
.PHONY: all
52+
all: lint build-all test test-acceptance
53+
54+
$(OUT_DIR):
55+
mkdir -p "$(OUT_DIR)"

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# grafana-image-renderer
2+
3+
A backend service for Grafana.
4+
It provides panel and dashboard rendering with a headless browser (Chromium).
5+
You can get your favourite dashboards as PDFs, PNGs, or with Grafana Enterprise, CSVs and even over emails with Grafana Reports.
6+
7+
## Installation
8+
9+
You can find installation details in the [docs](/docs/sources/_index.md).
10+
11+
<!-- FIXME: Use the grafana.com docs when it's published -->
12+
13+
## Compile
14+
15+
To compile the Go service, run:
16+
17+
```shell
18+
$ go build -buildvcs -o grafana-image-renderer .
19+
```
20+
21+
To compile the Docker image, run:
22+
23+
```shell
24+
$ docker build .
25+
```
26+
27+
The following tools are also useful for engineers:
28+
29+
```shell
30+
$ go tool goimports # our code formatter of choice
31+
$ golangci-lint run # our linter of choice
32+
$ IMAGE=tag-here go test ./tests/acceptance/... -count=1 # run acceptance tests
33+
```
34+
35+
## Release
36+
37+
When you are ready to make a release, tag it in Git (`git tag vX.Y.Z`; remember the `v` prefix), then push it.
38+
GitHub Actions deals with the build and deployment.

docs/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.ONESHELL:
2+
.DELETE_ON_ERROR:
3+
export SHELL := bash
4+
export SHELLOPTS := pipefail:errexit
5+
MAKEFLAGS += --warn-undefined-variables
6+
MAKEFLAGS += --no-builtin-rule
7+
8+
include docs.mk

docs/README.md

Lines changed: 6 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,9 @@
1-
# grafana-image-renderer
1+
# Documentation
22

3-
A backend service for Grafana.
4-
It provides panel and dashboard rendering with a headless browser (Chromium).
5-
You can get your favourite dashboards as PDFs, PNGs, or with Grafana Enterprise, CSVs and even over emails with Grafana Reports.
3+
If you're not in the docs directory, you can either `cd` in, or use `make -C
4+
docs <target...>`.
65

7-
## Installation
6+
To run a dev server, run `make docs`. This will automatically rebuild and
7+
refresh on changes.
88

9-
To install the service, you are recommended to use Docker or other containerisation software.
10-
We [ship images][image] for `linux/amd64` and `linux/arm64`; Windows and macOS can run these with Docker Desktop as well.
11-
We do not currently ship a binary you can run, nor do we ship a plugin.
12-
13-
To run the service in a stable manner, you are recommended to have a minimum of 16 GiB memory allocated to this service.
14-
You may also require a relatively modern CPU for decent output speeds.
15-
16-
### Install with Docker
17-
18-
While we ship a `latest` tag, you should generally prefer pinning a specific version in production environments.
19-
We do, however, commit to keeping the `latest` tag the latest stable release.
20-
21-
```shell
22-
$ docker network create grafana
23-
$ docker run --network grafana --name renderer --rm --detach grafana/grafana-image-renderer:latest
24-
# The following is not a production-ready Grafana instance, but shows what env vars you should set:
25-
$ docker run --network grafana --name grafana --rm --detach --env GF_RENDERING_SERVER_URL=http://renderer:8081/render --env http://grafana:3000/ --port 3000:3000 grafana/grafana-enterprise:latest
26-
```
27-
28-
Alternatively, if you prefer `docker compose`:
29-
30-
```yaml
31-
services:
32-
renderer:
33-
image: grafana/grafana-image-renderer:latest
34-
35-
grafana:
36-
image: grafana/grafana-enterprise:latest
37-
ports:
38-
- "3000:3000"
39-
environment:
40-
GF_RENDERING_SERVER_URL: http://renderer:8081/render
41-
GF_RENDERING_CALLBACK_URL: http://grafana:3000/
42-
```
43-
44-
If you are running with memory limits, you may want to set `GOMEMLIMIT` to a lower value than the limit, such as `1GiB`.
45-
You should not aim for the `GOMEMLIMIT` to match the container's limit: Chromium needs free memory on top.
46-
We recommend 1 GiB of `GOMEMLIMIT` per 8 GiB of container memory limit.
47-
48-
[image]: https://hub.docker.com/r/grafana/grafana-image-renderer
49-
50-
### Configuration
51-
52-
The service can be configured via several paths:
53-
54-
- Set CLI flags. See `--help` for the available flag names.
55-
- Use environment variables. See `--help` for the names and current values.
56-
Most, but not all, variables map 1:1 to the CLI flag names.
57-
- Use a JSON or YAML configuration file. This must be in the service's current working directory,
58-
and must be named one of `config.json`, `config.yaml`, or `config.yml`. Dot-separated keys are
59-
nested keys. E.g.: `a.b` becomes `{"a": {"b": "VALUE"}}` in the file.
60-
61-
The current configuration options can all be accessed by checking `--help`.
62-
63-
As an example, see: `docker run --rm grafana/grafana-image-renderer:latest server --help`.
64-
65-
### Security
66-
67-
The service requires a secret token to be present in all render requests.
68-
This token is set by `--server.auth-token` (`AUTH_TOKEN`); you can specify multiple and have a unique key per Grafana instance.
69-
By default, the token used is `-`.
70-
In Grafana, you must set this to match one of the tokens with the `[rendering] renderer_token` (`GF_RENDERING_RENDERER_TOKEN`) setting.
71-
72-
### Monitoring
73-
74-
You can monitor the service via Prometheus/[Mimir](https://grafana.com/oss/mimir) and any OpenTelemetry-compatible Tracing backend (like [Grafana Tempo](https://grafana.com/oss/tempo)).
75-
Metrics are exposed on `/metrics` and traces are sent as configured in the configuration options (see `--help`).
76-
77-
## Compile
78-
79-
To compile the Go service, run:
80-
81-
```shell
82-
$ go build -buildvcs -o grafana-image-renderer .
83-
```
84-
85-
To compile the Docker image, run:
86-
87-
```shell
88-
$ docker build .
89-
```
90-
91-
The following tools are also useful for engineers:
92-
93-
```shell
94-
$ go tool goimports # our code formatter of choice
95-
$ golangci-lint run # our linter of choice
96-
$ IMAGE=tag-here go test ./tests/acceptance/... -count=1 # run acceptance tests
97-
```
98-
99-
## Release
100-
101-
When you are ready to make a release, tag it in Git (`git tag vX.Y.Z`; remember the `v` prefix), then push it.
102-
GitHub Actions deals with the build and deployment.
9+
To run Vale, run `make vale`.

0 commit comments

Comments
 (0)