Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service: Support configuring host and port thru config and environment variables #40

Merged
merged 3 commits into from
Jan 19, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/master' into host-param
  • Loading branch information
marefr committed Jan 19, 2020
commit e5d7cda8ba210f17e0a3ed1c7350c7309993f594
44 changes: 35 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ aliases:
defaults: &defaults
working_directory: ~/grafana-image-renderer
docker:
- image: circleci/node:10.15.3-stretch
- image: circleci/node:12.13.1-stretch

jobs:
build:
Expand Down Expand Up @@ -117,6 +117,32 @@ jobs:
- store_artifacts:
path: artifacts

package_linux_x64_no_chromium:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: .
- restore_cache:
keys:
- dependency-cache-{{ checksum "yarn.lock" }}
- run:
name: Install dependencies
command: 'yarn install --pure-lockfile --no-progress'
- run:
name: Package
command: './scripts/package_target.sh linux-x64-glibc true plugin-linux-x64-glibc-no-chromium'
- run:
name: Archive
command: './scripts/archive_target.sh linux-x64-glibc plugin-linux-x64-glibc-no-chromium'
- persist_to_workspace:
root: .
paths:
- dist/*
- artifacts/*
- store_artifacts:
path: artifacts

publish-github-release:
working_directory: ~/grafana-image-renderer
docker:
Expand Down Expand Up @@ -147,14 +173,9 @@ jobs:
steps:
- checkout
- setup_remote_docker
- run: |
TAG=$(git describe --tags --abbrev=0 | cut -d "v" -f 2)
echo "building ${TAG}"
docker build -t ${IMAGE_NAME}:${TAG} .
docker tag ${IMAGE_NAME}:${TAG} ${IMAGE_NAME}:latest
echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin
docker push ${IMAGE_NAME}:${TAG}
docker push ${IMAGE_NAME}:latest
- run:
name: "Build and push Docker image"
command: ./scripts/build_push_docker.sh

workflows:
version: 2
Expand All @@ -174,13 +195,18 @@ workflows:
requires:
- build
filters: *filter-only-master
- package_linux_x64_no_chromium:
requires:
- build
filters: *filter-only-master
- approve-release:
type: approval
requires:
- build
- package_linux_x64
- package_darwin_x64
- package_windows_x64
- package_linux_x64_no_chromium
filters: *filter-only-master
- publish-github-release:
requires:
Expand Down
8 changes: 7 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
.circleci
.github
artifacts
build
devenv
dist
docker
docs
node_modules
scripts
.prettierignore
.prettierrc.json
dev.json
Dockerfile
debian.Dockerfile
Makefile
plugin_start*
tslint.json
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/1-bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Bug report
about: Report a bug
labels: 'type: bug'
---

<!--
Please use this template while reporting a bug and provide as much info as possible.
Questions should be posted to https://community.grafana.com
Refer to Grafana documentation to troubleshoot issues: https://grafana.com/docs/grafana/latest/administration/image_rendering/#troubleshooting
-->

**What happened**:

**What you expected to happen**:

**How to reproduce it (as minimally and precisely as possible)**:

**Anything else we need to know?**:

**Environment**:
- Grafana Image Renderer version:
- Grafana version:
- Installed plugin or remote renderer service:
- OS Grafana Image Renderer is installed on:
- User OS & Browser:
- Others:
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/2-enhancement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: Enhancement request
about: Suggest an enhancement or new feature
labels: 'type: feature request'
---

<!-- Please only use this template for submitting enhancement requests -->

**What would you like to be added**:

**Why is this needed**:
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Documentation
url: https://grafana.com/docs/grafana/latest/administration/image_rendering
about: For help, please read documentation and troubleshooting guide first.
- name: Questions & Help
url: https://community.grafana.com
about: Please ask and answer questions here.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ dist
build
artifacts

# API keys and secrets
.env

# Dependency directory
node_modules
bower_components
Expand Down
10 changes: 10 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.git
.github
artifacts
build
dist
docker
docs
node_modules
proto
scripts
5 changes: 5 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 150
}
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
## 1.0.8-beta1 (2019-12-17)

- Remote rendering: Collect and expose Prometheus metrics [#71](https://github.com/grafana/grafana-image-renderer/pull/71), [marefr](https://github.com/marefr)
- Build: Upgrade Node.js requirement to LTS (v12) [#57](https://github.com/grafana/grafana-image-renderer/pull/57), [marefr](https://github.com/marefr)

## 1.0.7 (2019-12-03)

- Provide correctly named config parameter to Chromium when overriding to skip https errors using environment variable `GF_RENDERER_PLUGIN_IGNORE_HTTPS_ERRORS` and/or `IGNORE_HTTPS_ERRORS` [#62](https://github.com/grafana/grafana-image-renderer/pull/62), [marefr](https://github.com/marefr)

## 1.0.6 (2019-11-25)

- Wait until all network connections to be idle before rendering [#24](https://github.com/grafana/grafana-image-renderer/pull/24), [d1ff](https://github.com/d1ff)
- Support ignoring https errors using environment variable [#59](https://github.com/grafana/grafana-image-renderer/pull/59), [marefr](https://github.com/marefr)
- Docker: Update dependencies to remove vulnerabilities [#53](https://github.com/grafana/grafana-image-renderer/pull/53), [marefr](https://github.com/marefr)
- Fix typo in log statement [#39](https://github.com/grafana/grafana-image-renderer/pull/39), [ankon](https://github.com/ankon)
- Updated documentation

## 1.0.5 (2019-09-11)

- Include md5 checksums in release artifacts
Expand Down
20 changes: 9 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
FROM node:10-alpine AS base
FROM node:12-alpine AS base

ENV CHROME_BIN="/usr/bin/chromium-browser"
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true"

WORKDIR /usr/src/app

RUN \
echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
&& echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \
&& echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
&& apk --no-cache update \
&& apk --no-cache upgrade \
&& apk add --no-cache --virtual .build-deps \
udev ttf-opensans chromium \
ca-certificates dumb-init \
&& rm -rf /var/cache/apk/* /tmp/*
echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \
echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories && \
echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
apk --no-cache upgrade && \
apk add --no-cache udev ttf-opensans unifont chromium ca-certificates dumb-init && \
rm -rf /tmp/*

FROM base as build

Expand All @@ -32,9 +29,10 @@ FROM base
COPY --from=build /usr/src/app/node_modules node_modules
COPY --from=build /usr/src/app/build build
COPY --from=build /usr/src/app/proto proto
COPY --from=build /usr/src/app/default.json config.json

EXPOSE 8081

ENTRYPOINT ["dumb-init", "--"]

CMD ["node", "build/app.js", "server", "--port=8081"]
CMD ["node", "build/app.js", "server", "--config=config.json"]
22 changes: 16 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
.PHONY: all clean deps build clean_package package archive build_package docker-alpine docker-debian

ARCH = darwin-x64-unknown
SKIP_CHROMIUM =
OUT =
DOCKER_TAG = dev

all: clean build

Expand All @@ -7,21 +12,26 @@ clean:

deps: node_modules

node_modules: package.json yarn.lock
node_modules: package.json yarn.lock ## Install node modules.
@echo "install frontend dependencies"
yarn install --pure-lockfile --no-progress

build:
./node_modules/.bin/tsc
yarn build

clean_package:
rm -rf .dist/plugin-${ARCH}
rm -f ./artifacts/plugin-${ARCH}.zip
./scripts/clean_target.sh ${ARCH} ${OUT}

package:
./scripts/package_target.sh ${ARCH}
./scripts/package_target.sh ${ARCH} ${SKIP_CHROMIUM} ${OUT}

archive:
./scripts/archive_target.sh ${ARCH}
./scripts/archive_target.sh ${ARCH} ${OUT}

build_package: clean clean_package build package archive

docker-alpine:
docker build -t grafana/grafana-image-renderer:${DOCKER_TAG} .

docker-debian:
docker build -t grafana/grafana-image-renderer:${DOCKER_TAG}-debian -f debian.Dockerfile .
54 changes: 36 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Grafana Image Renderer [![CircleCI](https://circleci.com/gh/grafana/grafana-image-renderer.svg?style=svg)](https://circleci.com/gh/grafana/grafana-image-renderer)

A Grafana backend plugin that handles rendering panels and dashboards to PNGs using headless Chrome.

## Requirements
Expand All @@ -10,44 +8,64 @@ A Grafana backend plugin that handles rendering panels and dashboards to PNGs us
- Windows (x64)
- Mac OS X (x64)

### No dependencies
### Dependencies

This plugin is packaged in a single executable with [Node.js](https://nodejs.org/) runtime and [Chromium browser](https://www.chromium.org/Home).
This means that you don't need to have Node.js and Chromium installed in your system for the plugin to function.

This plugin is packaged in a single executable with [Node.js](https://nodejs.org/) runtime and [Chromium](https://www.chromium.org/Home). It does not require any additional software to be installed on the Grafana server.
However, [Chromium browser](https://www.chromium.org/) depends on certain libraries and if you don't have all of those libraries installed in your
system you may encounter errors when trying to render an image. For further details and troubleshooting help, please refer to
[Grafana Image Rendering documentation](https://grafana.com/docs/administration/image_rendering/).

## Installation

### Using grafana-cli

**NOTE:** Installing this plugin using grafana-cli is supported from Grafana v6.4.

```
```bash
grafana-cli plugins install grafana-image-renderer
```

### Clone into plugins folder
### Install in Grafana Docker image

This plugin is not compatible with the current Grafana Docker image without installing further system-level dependencies. We recommend setting up another Docker container
for rendering and using remote rendering, see [Remote Rendering Using Docker](#remote-rendering-using-docker) for reference.

1. Git clone this repo into the Grafana external plugins folder.
2. Install dependencies and build.
If you still want to install the plugin in the Grafana docker image we provide instructions for how to build a custom Grafana image, see [Grafana Docker documentation](https://grafana.com/docs/installation/docker/#custom-image-with-grafana-image-renderer-plugin-pre-installed) for further instructions.

```
yarn install --pure-lockfile
yarn run build
```
### Environment variables

3. Restart Grafana.
You can override certain settings by using environment variables and making sure that those are available for the Grafana process.

**Default timezone:**

Instruct headless Chrome to use a default timezone when not provided by Grafana, .e.g. when rendering panel image of alert. See [ICU’s metaZones.txt](https://cs.chromium.org/chromium/src/third_party/icu/source/data/misc/metaZones.txt?rcl=faee8bc70570192d82d2978a71e2a615788597d1) for a list of supported timezone IDs.

```bash
TZ=Europe/Stockholm
```

**Ignore HTTPS errors:**

Instruct headless Chrome whether to ignore HTTPS errors during navigation. Per default HTTPS errors is not ignored.
Due to the security risk it's not recommended to ignore HTTPS errors.

```bash
GF_RENDERER_PLUGIN_IGNORE_HTTPS_ERRORS=true
```

## Remote Rendering Using Docker

Instead of installing and running the image renderer as a plugin, you can run it as a remote image rendering service using Docker. Read more about [remote rendering using Docker](https://github.com/grafana/grafana-image-renderer/blob/master/docs/remote_rendering_using_docker.md).

## Troubleshooting

To get more logging information, update the Grafana configuration:
For troubleshooting help, please refer to [Grafana Image Rendering documentation](https://grafana.com/docs/administration/image_rendering/#troubleshooting).

```
[log]
filters = rendering:debug
```
## Building from source

See [Building from source](https://github.com/grafana/grafana-image-renderer/blob/master/docs/building_from_source.md).

## Additional information

Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.