rozetko
7 months ago
26 changed files with 7056 additions and 7639 deletions
@ -0,0 +1,52 @@
|
||||
ARG grafana_version=latest |
||||
ARG grafana_image=grafana-enterprise |
||||
|
||||
FROM grafana/${grafana_image}:${grafana_version} |
||||
|
||||
ARG development=true |
||||
|
||||
|
||||
ENV DEV "${development}" |
||||
|
||||
# Make it as simple as possible to access the grafana instance for development purposes |
||||
# Do NOT enable these settings in a public facing / production grafana instance |
||||
ENV GF_AUTH_ANONYMOUS_ORG_ROLE "Admin" |
||||
ENV GF_AUTH_ANONYMOUS_ENABLED "true" |
||||
ENV GF_AUTH_BASIC_ENABLED "false" |
||||
# Set development mode so plugins can be loaded without the need to sign |
||||
ENV GF_DEFAULT_APP_MODE "development" |
||||
|
||||
|
||||
LABEL maintainer="Grafana Labs <hello@grafana.com>" |
||||
|
||||
ENV GF_PATHS_HOME="/usr/share/grafana" |
||||
WORKDIR $GF_PATHS_HOME |
||||
|
||||
USER root |
||||
|
||||
# Installing supervisor and inotify-tools |
||||
RUN if [ "${development}" = "true" ]; then \ |
||||
if grep -i -q alpine /etc/issue; then \ |
||||
apk add supervisor inotify-tools git; \ |
||||
elif grep -i -q ubuntu /etc/issue; then \ |
||||
DEBIAN_FRONTEND=noninteractive && \ |
||||
apt-get update && \ |
||||
apt-get install -y supervisor inotify-tools git && \ |
||||
rm -rf /var/lib/apt/lists/*; \ |
||||
else \ |
||||
echo 'ERROR: Unsupported base image' && /bin/false; \ |
||||
fi \ |
||||
fi |
||||
|
||||
COPY supervisord/supervisord.conf /etc/supervisor.d/supervisord.ini |
||||
COPY supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf |
||||
|
||||
|
||||
|
||||
# Inject livereload script into grafana index.html |
||||
RUN sed -i 's|</body>|<script src="http://localhost:35729/livereload.js"></script></body>|g' /usr/share/grafana/public/views/index.html |
||||
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh |
||||
RUN chmod +x /entrypoint.sh |
||||
ENTRYPOINT ["/entrypoint.sh"] |
@ -0,0 +1,18 @@
|
||||
#!/bin/sh |
||||
|
||||
if [ "${DEV}" = "false" ]; then |
||||
echo "Starting test mode" |
||||
exec /run.sh |
||||
fi |
||||
|
||||
echo "Starting development mode" |
||||
|
||||
if grep -i -q alpine /etc/issue; then |
||||
exec /usr/bin/supervisord -c /etc/supervisord.conf |
||||
elif grep -i -q ubuntu /etc/issue; then |
||||
exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf |
||||
else |
||||
echo 'ERROR: Unsupported base image' |
||||
exit 1 |
||||
fi |
||||
|
@ -0,0 +1,25 @@
|
||||
// Due to the grafana/ui Icon component making fetch requests to
|
||||
// `/public/img/icon/<icon_name>.svg` we need to mock react-inlinesvg to prevent
|
||||
// the failed fetch requests from displaying errors in console.
|
||||
|
||||
import React from 'react'; |
||||
|
||||
type Callback = (...args: any[]) => void; |
||||
|
||||
export interface StorageItem { |
||||
content: string; |
||||
queue: Callback[]; |
||||
status: string; |
||||
} |
||||
|
||||
export const cacheStore: { [key: string]: StorageItem } = Object.create(null); |
||||
|
||||
const SVG_FILE_NAME_REGEX = /(.+)\/(.+)\.svg$/; |
||||
|
||||
const InlineSVG = ({ src }: { src: string }) => { |
||||
// testId will be the file name without extension (e.g. `public/img/icons/angle-double-down.svg` -> `angle-double-down`)
|
||||
const testId = src.replace(SVG_FILE_NAME_REGEX, '$2'); |
||||
return <svg xmlns="http://www.w3.org/2000/svg" data-testid={testId} viewBox="0 0 24 24" />; |
||||
}; |
||||
|
||||
export default InlineSVG; |
@ -0,0 +1,15 @@
|
||||
[supervisord] |
||||
nodaemon=true |
||||
user=root |
||||
|
||||
[program:grafana] |
||||
user=root |
||||
directory=/var/lib/grafana |
||||
command=/run.sh |
||||
stdout_logfile=/dev/fd/1 |
||||
stdout_logfile_maxbytes=0 |
||||
redirect_stderr=true |
||||
killasgroup=true |
||||
stopasgroup=true |
||||
autostart=true |
||||
|
@ -0,0 +1,37 @@
|
||||
// Image declarations
|
||||
declare module '*.gif' { |
||||
const src: string; |
||||
export default src; |
||||
} |
||||
|
||||
declare module '*.jpg' { |
||||
const src: string; |
||||
export default src; |
||||
} |
||||
|
||||
declare module '*.jpeg' { |
||||
const src: string; |
||||
export default src; |
||||
} |
||||
|
||||
declare module '*.png' { |
||||
const src: string; |
||||
export default src; |
||||
} |
||||
|
||||
declare module '*.webp' { |
||||
const src: string; |
||||
export default src; |
||||
} |
||||
|
||||
declare module '*.svg' { |
||||
const content: string; |
||||
export default content; |
||||
} |
||||
|
||||
// Font declarations
|
||||
declare module '*.woff'; |
||||
declare module '*.woff2'; |
||||
declare module '*.eot'; |
||||
declare module '*.ttf'; |
||||
declare module '*.otf'; |
@ -0,0 +1,2 @@
|
||||
export const SOURCE_DIR = 'src'; |
||||
export const DIST_DIR = 'dist'; |
@ -0,0 +1,58 @@
|
||||
import fs from 'fs'; |
||||
import process from 'process'; |
||||
import os from 'os'; |
||||
import path from 'path'; |
||||
import { glob } from 'glob'; |
||||
import { SOURCE_DIR } from './constants'; |
||||
|
||||
export function isWSL() { |
||||
if (process.platform !== 'linux') { |
||||
return false; |
||||
} |
||||
|
||||
if (os.release().toLowerCase().includes('microsoft')) { |
||||
return true; |
||||
} |
||||
|
||||
try { |
||||
return fs.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft'); |
||||
} catch { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
export function getPackageJson() { |
||||
return require(path.resolve(process.cwd(), 'package.json')); |
||||
} |
||||
|
||||
export function getPluginJson() { |
||||
return require(path.resolve(process.cwd(), `${SOURCE_DIR}/plugin.json`)); |
||||
} |
||||
|
||||
export function hasReadme() { |
||||
return fs.existsSync(path.resolve(process.cwd(), SOURCE_DIR, 'README.md')); |
||||
} |
||||
|
||||
// Support bundling nested plugins by finding all plugin.json files in src directory
|
||||
// then checking for a sibling module.[jt]sx? file.
|
||||
export async function getEntries(): Promise<Record<string, string>> { |
||||
const pluginsJson = await glob('**/src/**/plugin.json', { absolute: true }); |
||||
|
||||
const plugins = await Promise.all( |
||||
pluginsJson.map((pluginJson) => { |
||||
const folder = path.dirname(pluginJson); |
||||
return glob(`${folder}/module.{ts,tsx,js,jsx}`, { absolute: true }); |
||||
}) |
||||
); |
||||
|
||||
return plugins.reduce((result, modules) => { |
||||
return modules.reduce((result, module) => { |
||||
const pluginPath = path.dirname(module); |
||||
const pluginName = path.relative(process.cwd(), pluginPath).replace(/src\/?/i, ''); |
||||
const entryName = pluginName === '' ? 'module' : `${pluginName}/module`; |
||||
|
||||
result[entryName] = module; |
||||
return result; |
||||
}, result); |
||||
}, {}); |
||||
} |
@ -1,3 +1,4 @@
|
||||
module.exports = { |
||||
...require('./node_modules/@grafana/toolkit/src/config/prettier.plugin.config.json'), |
||||
// Prettier configuration provided by Grafana scaffolding
|
||||
...require('./.config/.prettierrc.js'), |
||||
}; |
||||
|
@ -0,0 +1,26 @@
|
||||
version: '3.0' |
||||
|
||||
services: |
||||
grafana: |
||||
user: root |
||||
container_name: 'corpglory-chartwerk-panel' |
||||
|
||||
platform: 'linux/amd64' |
||||
build: |
||||
context: ./.config |
||||
args: |
||||
grafana_image: ${GRAFANA_IMAGE:-grafana-enterprise} |
||||
grafana_version: ${GRAFANA_VERSION:-10.3.3} |
||||
ports: |
||||
- 3000:3000/tcp |
||||
volumes: |
||||
- ./dist:/var/lib/grafana/plugins/corpglory-chartwerk-panel |
||||
- ./provisioning:/etc/grafana/provisioning |
||||
- .:/root/corpglory-chartwerk-panel |
||||
|
||||
environment: |
||||
NODE_ENV: development |
||||
GF_LOG_FILTERS: plugin.corpglory-chartwerk-panel:debug |
||||
GF_LOG_LEVEL: debug |
||||
GF_DATAPROXY_LOGGING: 1 |
||||
GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS: corpglory-chartwerk-panel |
@ -0,0 +1,2 @@
|
||||
// Jest setup provided by Grafana scaffolding
|
||||
import './.config/jest-setup'; |
@ -1,8 +1,8 @@
|
||||
// This file is needed because it is used by vscode and other tools that
|
||||
// call `jest` directly. However, unless you are doing anything special
|
||||
// do not edit this file
|
||||
// force timezone to UTC to allow tests to work regardless of local timezone
|
||||
// generally used by snapshots, but can affect specific tests
|
||||
process.env.TZ = 'UTC'; |
||||
|
||||
const standard = require('@grafana/toolkit/src/config/jest.plugin.config'); |
||||
|
||||
// This process will use the same config that `yarn test` is using
|
||||
module.exports = standard.jestConfig(); |
||||
module.exports = { |
||||
// Jest configuration provided by Grafana scaffolding
|
||||
...require('./.config/jest.config'), |
||||
}; |
||||
|
@ -1,9 +1,3 @@
|
||||
{ |
||||
"extends": "./node_modules/@grafana/toolkit/src/config/tsconfig.plugin.json", |
||||
"include": ["src", "types"], |
||||
"compilerOptions": { |
||||
"rootDir": "./src", |
||||
"baseUrl": "./src", |
||||
"typeRoots": ["./node_modules/@types"] |
||||
} |
||||
"extends": "./.config/tsconfig.json" |
||||
} |
||||
|
@ -1,7 +0,0 @@
|
||||
module.exports.getWebpackConfig = (config, options) => { |
||||
const d3Idx = config.externals.indexOf('d3'); |
||||
if(d3Idx !== -1) { |
||||
config.externals.splice(d3Idx, 1); |
||||
} |
||||
return config; |
||||
}; |
Loading…
Reference in new issue