diff --git a/grafana/grafana/12.2.0/0001-Add-loong64-support.patch b/grafana/grafana/12.2.0/0001-Add-loong64-support.patch new file mode 100644 index 00000000..c9084296 --- /dev/null +++ b/grafana/grafana/12.2.0/0001-Add-loong64-support.patch @@ -0,0 +1,256 @@ +From 16a370a02474918755c8430a4427b13121dbf078 Mon Sep 17 00:00:00 2001 +From: Huang Yang +Date: Mon, 18 May 2026 17:03:56 +0800 +Subject: [PATCH] Add loong64 support + +--- + Dockerfile | 138 +++++++++-------------------------------------------- + Makefile | 7 +-- + 2 files changed, 26 insertions(+), 119 deletions(-) + +diff --git a/Dockerfile b/Dockerfile +index 7d061e38..2a512e3b 100644 +--- a/Dockerfile ++++ b/Dockerfile +@@ -1,61 +1,13 @@ +-# syntax=docker/dockerfile:1 +- +-# to maintain formatting of multiline commands in vscode, add the following to settings.json: +-# "docker.languageserver.formatter.ignoreMultilineInstructions": true +- +-ARG BASE_IMAGE=alpine-base +-ARG GO_IMAGE=go-builder-base ++ARG BASE_IMAGE=alpine:3.11 ++ARG GO_IMAGE=golang:1.24.6-alpine + ARG JS_IMAGE=js-builder-base + ARG JS_PLATFORM=linux/amd64 + +-# Default to building locally + ARG GO_SRC=go-builder + ARG JS_SRC=js-builder + +-# Dependabot cannot update dependencies listed in ARGs +-# By using FROM instructions we can delegate dependency updates to dependabot +-FROM alpine:3.21.3 AS alpine-base +-FROM ubuntu:22.04 AS ubuntu-base +-FROM golang:1.24.6-alpine AS go-builder-base +-FROM --platform=${JS_PLATFORM} node:22-alpine AS js-builder-base +-# Javascript build stage ++# Javascript build stage - we only need the prebuilt public/ from the official image + FROM --platform=${JS_PLATFORM} ${JS_IMAGE} AS js-builder +-ARG JS_NODE_ENV=production +-ARG JS_YARN_INSTALL_FLAG=--immutable +-ARG JS_YARN_BUILD_FLAG=build +- +-ENV NODE_OPTIONS=--max_old_space_size=8000 +- +-WORKDIR /tmp/grafana +- +-RUN apk add --no-cache make build-base python3 +- +-COPY package.json project.json nx.json yarn.lock .yarnrc.yml ./ +-COPY .yarn .yarn +-COPY packages packages +-COPY e2e-playwright e2e-playwright +-COPY public public +-COPY LICENSE ./ +-COPY conf/defaults.ini ./conf/defaults.ini +-COPY e2e e2e +- +-# +-# Set the node env according to defaults or argument passed +-# +-ENV NODE_ENV=${JS_NODE_ENV} +-# +-RUN if [ "$JS_YARN_INSTALL_FLAG" = "" ]; then \ +- yarn install; \ +- else \ +- yarn install --immutable; \ +- fi +- +-COPY tsconfig.json eslint.config.js .editorconfig .browserslistrc .prettierrc.js ./ +-COPY scripts scripts +-COPY emails emails +- +-# Set the build argument according to default or argument passed +-RUN yarn ${JS_YARN_BUILD_FLAG} + + # Golang build stage + FROM ${GO_IMAGE} AS go-builder +@@ -65,51 +17,32 @@ ARG BUILD_BRANCH="" + ARG GO_BUILD_TAGS="oss" + ARG WIRE_TAGS="oss" + +-RUN if grep -i -q alpine /etc/issue; then \ +- apk add --no-cache \ +- # This is required to allow building on arm64 due to https://github.com/golang/go/issues/22040 +- binutils-gold \ +- bash \ +- # Install build dependencies +- gcc g++ make git; \ ++# Install build dependencies (version-aware, based on 12.0.8 patch) ++RUN set -eux; \ ++ if grep -i -q alpine /etc/issue; then \ ++ sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories; \ ++ apk add --no-cache \ ++ bash \ ++ gcc g++ make git; \ ++ ver=`awk -F '[=.]+' '$1=="VERSION_ID"{print $3}' /etc/os-release`; \ ++ if [ "${ver}" -ge 23 ]; then \ ++ apk add --no-cache binutils; \ ++ fi; \ + fi + ++ENV GOTOOLCHAIN=local ++ARG GOPROXY=https://goproxy.cn,direct ++ENV GOPROXY=${GOPROXY} ++ + WORKDIR /tmp/grafana + + COPY go.* ./ + COPY .citools .citools + +-# Copy go dependencies first +-# If updating this, please also update devenv/frontend-service/backend.dockerfile + COPY pkg/util/xorm pkg/util/xorm +-COPY pkg/apiserver pkg/apiserver +-COPY pkg/apimachinery pkg/apimachinery +-COPY pkg/build pkg/build +-COPY pkg/build/wire pkg/build/wire +-COPY pkg/promlib pkg/promlib +-COPY pkg/storage/unified/resource pkg/storage/unified/resource +-COPY pkg/storage/unified/resourcepb pkg/storage/unified/resourcepb +-COPY pkg/storage/unified/apistore pkg/storage/unified/apistore +-COPY pkg/semconv pkg/semconv +-COPY pkg/aggregator pkg/aggregator +-COPY apps/playlist apps/playlist +-COPY apps/plugins apps/plugins +-COPY apps/shorturl apps/shorturl +-COPY apps/preferences apps/preferences +-COPY apps/provisioning apps/provisioning +-COPY apps/secret apps/secret +-COPY apps/investigations apps/investigations +-COPY apps/advisor apps/advisor +-COPY apps/dashboard apps/dashboard +-COPY apps/folder apps/folder +-COPY apps/preferences apps/preferences +-COPY apps/iam apps/iam ++COPY pkg pkg + COPY apps apps + COPY kindsv2 kindsv2 +-COPY apps/alerting/notifications apps/alerting/notifications +-COPY apps/alerting/alertenrichment apps/alerting/alertenrichment +-COPY pkg/codegen pkg/codegen +-COPY pkg/plugins/codegen pkg/plugins/codegen + + RUN go mod download + +@@ -120,7 +53,6 @@ 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 +@@ -130,23 +62,9 @@ ENV BUILD_BRANCH=${BUILD_BRANCH} + + RUN make build-go GO_BUILD_TAGS=${GO_BUILD_TAGS} WIRE_TAGS=${WIRE_TAGS} + +-# From-tarball build stage +-FROM ${BASE_IMAGE} AS tgz-builder +- +-WORKDIR /tmp/grafana +- +-ARG GRAFANA_TGZ="grafana-latest.linux-x64-musl.tar.gz" +- +-COPY ${GRAFANA_TGZ} /tmp/grafana.tar.gz +- +-# add -v to make tar print every file it extracts +-RUN tar x -z -f /tmp/grafana.tar.gz --strip-components=1 +- +-# helpers for COPY --from + FROM ${GO_SRC} AS go-src + FROM ${JS_SRC} AS js-src + +-# Final stage + FROM ${BASE_IMAGE} + + LABEL maintainer="Grafana Labs " +@@ -165,7 +83,6 @@ ENV PATH="/usr/share/grafana/bin:$PATH" \ + + WORKDIR $GF_PATHS_HOME + +-# Install dependencies + RUN if grep -i -q alpine /etc/issue; then \ + apk add --no-cache ca-certificates bash curl tzdata musl-utils && \ + apk info -vv | sort; \ +@@ -179,21 +96,10 @@ RUN if grep -i -q alpine /etc/issue; then \ + echo 'ERROR: Unsupported base image' && /bin/false; \ + fi + +-# glibc support for alpine x86_64 only +-# docker run --rm --env STDOUT=1 sgerrand/glibc-builder 2.40 /usr/glibc-compat > glibc-bin-2.40.tar.gz + ARG GLIBC_VERSION=2.40 + + RUN if grep -i -q alpine /etc/issue && [ `arch` = "x86_64" ]; then \ +- wget -qO- "https://dl.grafana.com/glibc/glibc-bin-$GLIBC_VERSION.tar.gz" | tar zxf - -C / \ +- usr/glibc-compat/lib/ld-linux-x86-64.so.2 \ +- usr/glibc-compat/lib/libc.so.6 \ +- usr/glibc-compat/lib/libdl.so.2 \ +- usr/glibc-compat/lib/libm.so.6 \ +- usr/glibc-compat/lib/libpthread.so.0 \ +- usr/glibc-compat/lib/librt.so.1 \ +- usr/glibc-compat/lib/libresolv.so.2 && \ +- mkdir /lib64 && \ +- ln -s /usr/glibc-compat/lib/ld-linux-x86-64.so.2 /lib64; \ ++ echo "Skipping glibc for non-x86_64"; \ + fi + + COPY --from=go-src /tmp/grafana/conf ./conf +@@ -227,8 +133,8 @@ RUN if [ ! $(getent group "$GF_GID") ]; then \ + chmod -R 777 "$GF_PATHS_DATA" "$GF_PATHS_HOME/.aws" "$GF_PATHS_LOGS" "$GF_PATHS_PLUGINS" "$GF_PATHS_PROVISIONING" + + COPY --from=go-src /tmp/grafana/bin/grafana* /tmp/grafana/bin/*/grafana* ./bin/ +-COPY --from=js-src /tmp/grafana/public ./public +-COPY --from=js-src /tmp/grafana/LICENSE ./ ++COPY --from=js-src $GF_PATHS_HOME/public ./public ++COPY --from=js-src $GF_PATHS_HOME/LICENSE ./ + + EXPOSE 3000 + +diff --git a/Makefile b/Makefile +index 1885015a..dcd2f49d 100644 +--- a/Makefile ++++ b/Makefile +@@ -397,7 +397,8 @@ shellcheck: $(SH_FILES) ## Run checks for shell scripts. + ##@ Docker + + TAG_SUFFIX=$(if $(WIRE_TAGS)!=oss,-$(WIRE_TAGS)) +-PLATFORM=linux/amd64 ++PLATFORM ?= linux/amd64 ++IMG_NAME ?= grafana/grafana$(TAG_SUFFIX):dev + + # default to a production build for frontend + # +@@ -422,7 +423,7 @@ endif + build-docker-full: ## Build Docker image for development. + @echo "build docker container mode=($(DOCKER_JS_NODE_ENV_FLAG))" + tar -ch . | \ +- docker buildx build - \ ++ docker build - \ + --platform $(PLATFORM) \ + --build-arg NODE_ENV=$(DOCKER_JS_NODE_ENV_FLAG) \ + --build-arg JS_NODE_ENV=$(DOCKER_JS_NODE_ENV_FLAG) \ +@@ -432,7 +433,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 $(IMG_NAME) \ + $(DOCKER_BUILD_ARGS) + + .PHONY: build-docker-full-ubuntu +-- +2.27.0 + diff --git a/grafana/grafana/12.2.0/Makefile b/grafana/grafana/12.2.0/Makefile new file mode 100644 index 00000000..750da9e8 --- /dev/null +++ b/grafana/grafana/12.2.0/Makefile @@ -0,0 +1,40 @@ +# This file is generated by the template. + +REGISTRY?=cr.loongnix.cn +ORGANIZATION?=grafana +REPOSITORY?=grafana +TAG?=12.2.0 +LATEST?=false + +IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(TAG) +LATEST_IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):latest + +# SOURCE_URL is a url to download source, such as https://github.com/merore/merore.git. +# SOURCE is project sources, its located at src/$(SORUCE). +# PATCH is a patch that supports loong64 to $(SOURCE). +# Be sure to fill in the follows!!! +SOURCE_URL=https://github.com/grafana/grafana.git +SOURCE=$(shell echo $(SOURCE_URL) | awk -F '/' '{print $$NF}' | awk -F '.' '{print $$1}') +PATCH=0001-Add-loong64-support.patch + +default: image + +src/$(SOURCE): + git clone -b v$(TAG) --depth=1 $(SOURCE_URL) $@ + cd $@ && \ + git apply ../../$(PATCH) + + +image: src/$(SOURCE) +# Commands for building. + IMG_NAME=$(IMAGE) PLATFORM=linux/loong64 \ + DOCKER_BUILD_ARGS="--build-arg BASE_IMAGE=cr.loongnix.cn/library/alpine:3.11 \ + --build-arg JS_IMAGE=docker.m.daocloud.io/grafana/grafana:$(TAG) \ + --build-arg GO_IMAGE=cr.loongnix.cn/library/golang:1.25-alpine" \ + $(MAKE) -C src/$(SOURCE) build-docker-full + +push: + docker push $(IMAGE) + +clean: + rm -rf src