From 7ed824c43864b6ce975cbf127f11b90c009ee03b Mon Sep 17 00:00:00 2001 From: Mykola Polonskyi Date: Thu, 11 Apr 2024 16:10:11 +0300 Subject: [PATCH 1/7] Use original docker file --- Dockerfile | 77 ++++++++++++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 40 deletions(-) diff --git a/Dockerfile b/Dockerfile index a44307714872b..18a519cbfa89c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,33 +1,33 @@ # syntax=docker/dockerfile:1 -ARG BASE_IMAGE=406095609952.dkr.ecr.us-east-1.amazonaws.com/alpine:3.12.1 -ARG JS_IMAGE=406095609952.dkr.ecr.us-east-1.amazonaws.com/node:20.8.1-alpine +ARG BASE_IMAGE=alpine:3.19.1 +ARG JS_IMAGE=node:20-alpine ARG JS_PLATFORM=linux/amd64 -ARG GO_IMAGE=406095609952.dkr.ecr.us-east-1.amazonaws.com/golang:1.21.8-alpine +ARG GO_IMAGE=golang:1.21.8-alpine ARG GO_SRC=go-builder ARG JS_SRC=js-builder -FROM ${JS_IMAGE} as js-builder +FROM --platform=${JS_PLATFORM} ${JS_IMAGE} as js-builder ENV NODE_OPTIONS=--max_old_space_size=8000 WORKDIR /tmp/grafana -COPY grafana/package.json grafana/yarn.lock grafana/.yarnrc.yml ./ -COPY grafana/.yarn .yarn -COPY grafana/packages packages -COPY grafana/plugins-bundled plugins-bundled -COPY grafana/public public +COPY package.json yarn.lock .yarnrc.yml ./ +COPY .yarn .yarn +COPY packages packages +COPY plugins-bundled plugins-bundled +COPY public public RUN apk add --no-cache make build-base python3 RUN yarn install --immutable -COPY grafana/tsconfig.json grafana/.eslintrc grafana/.editorconfig grafana/.browserslistrc grafana/.prettierrc.js ./ -COPY grafana/public public -COPY grafana/scripts scripts -COPY grafana/emails emails +COPY tsconfig.json .eslintrc .editorconfig .browserslistrc .prettierrc.js ./ +COPY public public +COPY scripts scripts +COPY emails emails ENV NODE_ENV production RUN yarn build @@ -40,6 +40,9 @@ ARG GO_BUILD_TAGS="oss" ARG WIRE_TAGS="oss" ARG BINGO="true" +# This is required to allow building on arm64 due to https://github.com/golang/go/issues/22040 +RUN apk add --no-cache binutils-gold + # Install build dependencies RUN if grep -i -q alpine /etc/issue; then \ apk add --no-cache gcc g++ make git; \ @@ -47,11 +50,14 @@ RUN if grep -i -q alpine /etc/issue; then \ WORKDIR /tmp/grafana -COPY grafana/go.* ./ -COPY grafana/.bingo .bingo +COPY go.* ./ +COPY .bingo .bingo # Include vendored dependencies -COPY grafana/pkg/util/xorm/go.* pkg/util/xorm/ +COPY pkg/util/xorm/go.* pkg/util/xorm/ +COPY pkg/apiserver/go.* pkg/apiserver/ +COPY pkg/apimachinery/go.* pkg/apimachinery/ +COPY pkg/promlib/go.* pkg/promlib/ RUN go mod download RUN if [[ "$BINGO" = "true" ]]; then \ @@ -59,18 +65,18 @@ RUN if [[ "$BINGO" = "true" ]]; then \ bingo get -v; \ fi -COPY grafana/embed.go grafana/Makefile grafana/build.go grafana/package.json ./ -COPY grafana/cue.mod cue.mod -COPY grafana/kinds kinds -COPY grafana/local local -COPY grafana/packages/grafana-schema packages/grafana-schema -COPY grafana/public/app/plugins public/app/plugins -COPY grafana/public/api-merged.json public/api-merged.json -COPY grafana/pkg pkg -COPY grafana/scripts scripts -COPY grafana/conf conf -COPY grafana/.github .github -COPY grafana/LICENSE ./ +COPY embed.go Makefile build.go package.json ./ +COPY cue.mod cue.mod +COPY kinds kinds +COPY local local +COPY packages/grafana-schema packages/grafana-schema +COPY public/app/plugins public/app/plugins +COPY public/api-merged.json public/api-merged.json +COPY pkg pkg +COPY scripts scripts +COPY conf conf +COPY .github .github +COPY LICENSE ./ ENV COMMIT_SHA=${COMMIT_SHA} ENV BUILD_BRANCH=${BUILD_BRANCH} @@ -174,20 +180,11 @@ COPY --from=go-src /tmp/grafana/bin/grafana* /tmp/grafana/bin/*/grafana* ./bin/ COPY --from=js-src /tmp/grafana/public ./public COPY --from=go-src /tmp/grafana/LICENSE ./ -# LOGZ.IO GRAFANA CHANGE :: Copy custom.ini -COPY custom.ini conf/custom.ini -RUN cp "$GF_PATHS_HOME/conf/custom.ini" "$GF_PATHS_CONFIG" -# LOGZ.IO GRAFANA CHANGE :: Preinstall plugins -# COPY grafana/data/plugins "$GF_PATHS_PLUGINS" -# LOGZ.IO GRAFANA CHANGE :: Remove news panel -RUN rm -rf ./public/app/plugins/panel/news -# LOGZ.IO GRAFANA CHANGE :: Remove pluginlist panel - but it does not exist in v10 -# RUN rm -rf ./public/app/plugins/panel/pluginlist -EXPOSE 3333 +EXPOSE 3000 -ARG RUN_SH=grafana/packaging/docker/run.sh +ARG RUN_SH=./packaging/docker/run.sh COPY ${RUN_SH} /run.sh USER "$GF_UID" -ENTRYPOINT [ "/run.sh" ] +ENTRYPOINT [ "/run.sh" ] \ No newline at end of file From d72bcf82e6fbfc20594246e59f607cd5cc817eb3 Mon Sep 17 00:00:00 2001 From: Mykola Polonskyi Date: Thu, 11 Apr 2024 16:17:30 +0300 Subject: [PATCH 2/7] Use original docker file --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 18a519cbfa89c..b4591d3321cd2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -186,5 +186,6 @@ ARG RUN_SH=./packaging/docker/run.sh COPY ${RUN_SH} /run.sh + USER "$GF_UID" ENTRYPOINT [ "/run.sh" ] \ No newline at end of file From 070670417cede2eaa4f67950b3d07655aed85382 Mon Sep 17 00:00:00 2001 From: Mykola Polonskyi Date: Fri, 12 Apr 2024 10:52:17 +0300 Subject: [PATCH 3/7] Use original docker file --- Dockerfile | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index b4591d3321cd2..d63f6abb8230b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,9 +40,6 @@ ARG GO_BUILD_TAGS="oss" ARG WIRE_TAGS="oss" ARG BINGO="true" -# This is required to allow building on arm64 due to https://github.com/golang/go/issues/22040 -RUN apk add --no-cache binutils-gold - # Install build dependencies RUN if grep -i -q alpine /etc/issue; then \ apk add --no-cache gcc g++ make git; \ @@ -55,9 +52,6 @@ COPY .bingo .bingo # Include vendored dependencies COPY pkg/util/xorm/go.* pkg/util/xorm/ -COPY pkg/apiserver/go.* pkg/apiserver/ -COPY pkg/apimachinery/go.* pkg/apimachinery/ -COPY pkg/promlib/go.* pkg/promlib/ RUN go mod download RUN if [[ "$BINGO" = "true" ]]; then \ @@ -186,6 +180,5 @@ ARG RUN_SH=./packaging/docker/run.sh COPY ${RUN_SH} /run.sh - USER "$GF_UID" ENTRYPOINT [ "/run.sh" ] \ No newline at end of file From bc15f9f1dc98ab73a95b976b6887e6c0a424f2cf Mon Sep 17 00:00:00 2001 From: Mykola Polonskyi Date: Mon, 15 Apr 2024 13:30:02 +0300 Subject: [PATCH 4/7] Use original docker file --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 25904afef5909..48106d30b4b19 100644 --- a/Makefile +++ b/Makefile @@ -242,7 +242,7 @@ build-docker-full: ## Build Docker image for development. --build-arg WIRE_TAGS=$(WIRE_TAGS) \ --build-arg COMMIT_SHA=$$(git rev-parse HEAD) \ --build-arg BUILD_BRANCH=$$(git rev-parse --abbrev-ref HEAD) \ - --tag grafana/grafana$(TAG_SUFFIX):dev \ + --tag 406095609952.dkr.ecr.us-east-1.amazonaws.com/grafana-10:dev \ $(DOCKER_BUILD_ARGS) build-docker-full-ubuntu: ## Build Docker image based on Ubuntu for development. From 628a953e15c88d8d4527fed898d33603fba7afd3 Mon Sep 17 00:00:00 2001 From: Mykola Polonskyi Date: Thu, 25 Apr 2024 12:59:27 +0300 Subject: [PATCH 5/7] Publish grafana to different repo --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 48106d30b4b19..1dc4103745923 100644 --- a/Makefile +++ b/Makefile @@ -231,6 +231,7 @@ shellcheck: $(SH_FILES) ## Run checks for shell scripts. TAG_SUFFIX=$(if $(WIRE_TAGS)!=oss,-$(WIRE_TAGS)) PLATFORM=linux/amd64 +GRAFANA_TAG=dev build-docker-full: ## Build Docker image for development. @echo "build docker container" @@ -242,7 +243,7 @@ build-docker-full: ## Build Docker image for development. --build-arg WIRE_TAGS=$(WIRE_TAGS) \ --build-arg COMMIT_SHA=$$(git rev-parse HEAD) \ --build-arg BUILD_BRANCH=$$(git rev-parse --abbrev-ref HEAD) \ - --tag 406095609952.dkr.ecr.us-east-1.amazonaws.com/grafana-10:dev \ + --tag 406095609952.dkr.ecr.us-east-1.amazonaws.com/grafana-x:$(GRAFANA_TAG) \ $(DOCKER_BUILD_ARGS) build-docker-full-ubuntu: ## Build Docker image based on Ubuntu for development. @@ -257,7 +258,7 @@ build-docker-full-ubuntu: ## Build Docker image based on Ubuntu for development. --build-arg BUILD_BRANCH=$$(git rev-parse --abbrev-ref HEAD) \ --build-arg BASE_IMAGE=ubuntu:22.04 \ --build-arg GO_IMAGE=golang:1.21.8 \ - --tag grafana/grafana$(TAG_SUFFIX):dev-ubuntu \ + --tag 406095609952.dkr.ecr.us-east-1.amazonaws.com/grafana-x:$(GRAFANA_TAG)-ubuntu \ $(DOCKER_BUILD_ARGS) ##@ Services From 4b141223218d5537a3ab9c0e627d18a9efb92ab7 Mon Sep 17 00:00:00 2001 From: Mykola Polonskyi Date: Mon, 29 Apr 2024 12:28:10 +0300 Subject: [PATCH 6/7] Some configs --- Dockerfile | 5 +++- config.js | 9 ++++++ custom.ini | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 config.js create mode 100644 custom.ini diff --git a/Dockerfile b/Dockerfile index d63f6abb8230b..917df48788fe1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -174,7 +174,10 @@ COPY --from=go-src /tmp/grafana/bin/grafana* /tmp/grafana/bin/*/grafana* ./bin/ COPY --from=js-src /tmp/grafana/public ./public COPY --from=go-src /tmp/grafana/LICENSE ./ -EXPOSE 3000 +COPY custom.ini conf/custom.ini +RUN cp "$GF_PATHS_HOME/conf/custom.ini" "$GF_PATHS_CONFIG" + +EXPOSE 3333 ARG RUN_SH=./packaging/docker/run.sh diff --git a/config.js b/config.js new file mode 100644 index 0000000000000..7c9b670927f2a --- /dev/null +++ b/config.js @@ -0,0 +1,9 @@ +const Joi = require('joi'); + +const schema = Joi.object({ + serviceName: Joi.string().default('grafana-x'), + port: Joi.number().default(3333), +}); + + +module.exports = { schema }; diff --git a/custom.ini b/custom.ini new file mode 100644 index 0000000000000..1380b0a117913 --- /dev/null +++ b/custom.ini @@ -0,0 +1,85 @@ +app_mode = development +[server] +http_port = 3333 +domain = grafana-service +root_url = %(protocol)s://%(domain)s:3333/grafana-app +static_root_path = public/ +router_logging = true +enable_gzip = false + +;root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana-app +;serve_from_sub_path = true + +[users] +auto_assign_org_role = Editor +viewers_can_edit = true +allow_sign_up = false +default_theme = dark +case_insensitive_login = false + +[auth.proxy] +enabled = true +header_name = X-LOGZ-GRAFANA-TOKEN +header_property = username +auto_sign_up = false +org_name = Logz.io + +[database] +; type = sqlite3 +type = mysql +host = mysql:3306 +name = grafana_x +user = root +password = test + +[remote_cache] +type = database + +[auth] +disable_signout_menu = true +disable_login_form = true + +[live] +max_connections = 0 + +[news] +# Enable the news feed section +news_feed_enabled = false + +[alerting] +enabled = false +execute_alerts = false +min_interval_seconds = 60 + +[unified_alerting] +enabled = true +execute_alerts = false +alert_manager_enabled = true + +[security] +disable_gravatar = true +allow_embedding = true +x_xss_protection = true +content_security_policy = true +content_security_policy_template = """script-src *.guides.logz.io *.pendo.io pendo-io-static.storage.googleapis.com pendo-static-6219552081182720.storage.googleapis.com 'unsafe-eval' 'strict-dynamic' $NONCE;object-src 'none';font-src 'self';style-src *.guides.logz.io *.pendo.io pendo-io-static.storage.googleapis.com pendo-static-6219552081182720.storage.googleapis.com 'self' 'unsafe-inline' blob:;img-src *.guides.logz.io *.pendo.io pendo-io-static.storage.googleapis.com pendo-static-6219552081182720.storage.googleapis.com 'self' data: *.global.ssl.fastly.net *.iconfinder.com;base-uri 'self';connect-src *.guides.logz.io *.pendo.io pendo-io-static.storage.googleapis.com pendo-static-6219552081182720.storage.googleapis.com 'self' grafana.com;manifest-src 'self';media-src 'none';block-all-mixed-content;frame-src 'self' https://www.youtube.com;""" + +[dashboards] +min_refresh_interval = 30s + +[log] +level = debug + +[analytics] +reporting_enabled = false +check_for_updates = false + +[snapshots] +external_enabled = false + +[dashboards] +min_refresh_interval = 30s + +[log.frontend] +enabled = true +custom_endpoint = log + From 232ac50bb82f5389481bcb54ce962a8bed07cf84 Mon Sep 17 00:00:00 2001 From: Mykola Polonskyi Date: Wed, 8 May 2024 14:12:00 +0300 Subject: [PATCH 7/7] Align docker file --- Dockerfile | 66 +++++++++++++++++++++++++++++------------------------- Makefile | 2 ++ 2 files changed, 38 insertions(+), 30 deletions(-) diff --git a/Dockerfile b/Dockerfile index 917df48788fe1..1fe18a7b61e57 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,33 +1,33 @@ # syntax=docker/dockerfile:1 -ARG BASE_IMAGE=alpine:3.19.1 -ARG JS_IMAGE=node:20-alpine +ARG BASE_IMAGE=406095609952.dkr.ecr.us-east-1.amazonaws.com/alpine:3.12.1 +ARG JS_IMAGE=406095609952.dkr.ecr.us-east-1.amazonaws.com/node:20.8.1-alpine ARG JS_PLATFORM=linux/amd64 -ARG GO_IMAGE=golang:1.21.8-alpine +ARG GO_IMAGE=406095609952.dkr.ecr.us-east-1.amazonaws.com/golang:1.21.8-alpine ARG GO_SRC=go-builder ARG JS_SRC=js-builder -FROM --platform=${JS_PLATFORM} ${JS_IMAGE} as js-builder +FROM ${JS_IMAGE} as js-builder ENV NODE_OPTIONS=--max_old_space_size=8000 WORKDIR /tmp/grafana -COPY package.json yarn.lock .yarnrc.yml ./ -COPY .yarn .yarn -COPY packages packages -COPY plugins-bundled plugins-bundled -COPY public public +COPY grafana/package.json grafana/yarn.lock grafana/.yarnrc.yml ./ +COPY grafana/.yarn .yarn +COPY grafana/packages packages +COPY grafana/plugins-bundled plugins-bundled +COPY grafana/public public RUN apk add --no-cache make build-base python3 RUN yarn install --immutable -COPY tsconfig.json .eslintrc .editorconfig .browserslistrc .prettierrc.js ./ -COPY public public -COPY scripts scripts -COPY emails emails +COPY grafana/tsconfig.json grafana/.eslintrc grafana/.editorconfig grafana/.browserslistrc grafana/.prettierrc.js ./ +COPY grafana/public public +COPY grafana/scripts scripts +COPY grafana/emails emails ENV NODE_ENV production RUN yarn build @@ -47,11 +47,11 @@ RUN if grep -i -q alpine /etc/issue; then \ WORKDIR /tmp/grafana -COPY go.* ./ -COPY .bingo .bingo +COPY grafana/go.* ./ +COPY grafana/.bingo .bingo # Include vendored dependencies -COPY pkg/util/xorm/go.* pkg/util/xorm/ +COPY grafana/pkg/util/xorm/go.* pkg/util/xorm/ RUN go mod download RUN if [[ "$BINGO" = "true" ]]; then \ @@ -59,18 +59,18 @@ RUN if [[ "$BINGO" = "true" ]]; then \ bingo get -v; \ fi -COPY embed.go Makefile build.go package.json ./ -COPY cue.mod cue.mod -COPY kinds kinds -COPY local local -COPY packages/grafana-schema packages/grafana-schema -COPY public/app/plugins public/app/plugins -COPY public/api-merged.json public/api-merged.json -COPY pkg pkg -COPY scripts scripts -COPY conf conf -COPY .github .github -COPY LICENSE ./ +COPY grafana/embed.go grafana/Makefile grafana/build.go grafana/package.json ./ +COPY grafana/cue.mod cue.mod +COPY grafana/kinds kinds +COPY grafana/local local +COPY grafana/packages/grafana-schema packages/grafana-schema +COPY grafana/public/app/plugins public/app/plugins +COPY grafana/public/api-merged.json public/api-merged.json +COPY grafana/pkg pkg +COPY grafana/scripts scripts +COPY grafana/conf conf +COPY grafana/.github .github +COPY grafana/LICENSE ./ ENV COMMIT_SHA=${COMMIT_SHA} ENV BUILD_BRANCH=${BUILD_BRANCH} @@ -174,12 +174,18 @@ COPY --from=go-src /tmp/grafana/bin/grafana* /tmp/grafana/bin/*/grafana* ./bin/ COPY --from=js-src /tmp/grafana/public ./public COPY --from=go-src /tmp/grafana/LICENSE ./ +# LOGZ.IO GRAFANA CHANGE :: Copy custom.ini COPY custom.ini conf/custom.ini RUN cp "$GF_PATHS_HOME/conf/custom.ini" "$GF_PATHS_CONFIG" - +# LOGZ.IO GRAFANA CHANGE :: Preinstall plugins +# COPY grafana/data/plugins "$GF_PATHS_PLUGINS" +# LOGZ.IO GRAFANA CHANGE :: Remove news panel +RUN rm -rf ./public/app/plugins/panel/news +# LOGZ.IO GRAFANA CHANGE :: Remove pluginlist panel - but it does not exist in v10 +# RUN rm -rf ./public/app/plugins/panel/pluginlist EXPOSE 3333 -ARG RUN_SH=./packaging/docker/run.sh +ARG RUN_SH=grafana/packaging/docker/run.sh COPY ${RUN_SH} /run.sh diff --git a/Makefile b/Makefile index c0434bf126fb2..4fd93cce4a3e8 100644 --- a/Makefile +++ b/Makefile @@ -252,6 +252,7 @@ build-docker-full: ## Build Docker image for development. @echo "build docker container" tar -ch . | \ docker buildx build - \ + -f Dockerfile.local \ --platform $(PLATFORM) \ --build-arg BINGO=false \ --build-arg GO_BUILD_TAGS=$(GO_BUILD_TAGS) \ @@ -265,6 +266,7 @@ build-docker-full-ubuntu: ## Build Docker image based on Ubuntu for development. @echo "build docker container" tar -ch . | \ docker buildx build - \ + -f Dockerfile.local \ --platform $(PLATFORM) \ --build-arg BINGO=false \ --build-arg GO_BUILD_TAGS=$(GO_BUILD_TAGS) \