Skip to content

Commit

Permalink
Add grafana:10.4.1
Browse files Browse the repository at this point in the history
export GOPROXY=https://goproxy.cn:
Set GOPROXY to fix download time out;

go get github.com/mattn/go-sqlite3:
Update go-sqlite3 to fix pread64 not found error;
  • Loading branch information
zhaixiaojuan committed Sep 3, 2024
1 parent dc5ddaa commit 2b29174
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 0 deletions.
1 change: 1 addition & 0 deletions grafana/grafana/10.4.1/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src
111 changes: 111 additions & 0 deletions grafana/grafana/10.4.1/0001-support-loong64.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
diff --git a/Dockerfile b/Dockerfile
index 5c156496..293a0491 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,3 @@
-# syntax=docker/dockerfile:1

ARG BASE_IMAGE=alpine:3.19.1
ARG JS_IMAGE=node:20-alpine
@@ -10,27 +9,6 @@ ARG JS_SRC=js-builder

FROM --platform=${JS_PLATFORM} ${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
-
-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
-
-ENV NODE_ENV production
-RUN yarn build

FROM ${GO_IMAGE} as go-builder

@@ -53,8 +31,8 @@ COPY .bingo .bingo
# Include vendored dependencies
COPY pkg/util/xorm/go.* pkg/util/xorm/

-RUN go mod download
-RUN if [[ "$BINGO" = "true" ]]; then \
+RUN export GOPROXY=https://goproxy.cn && go mod download
+RUN if [ "$BINGO" = "true" ]; then \
go install github.com/bwplotka/bingo@latest && \
bingo get -v; \
fi
@@ -75,18 +53,18 @@ COPY LICENSE ./
ENV COMMIT_SHA=${COMMIT_SHA}
ENV BUILD_BRANCH=${BUILD_BRANCH}

-RUN make build-go GO_BUILD_TAGS=${GO_BUILD_TAGS} WIRE_TAGS=${WIRE_TAGS}
+RUN go get github.com/mattn/go-sqlite3 && make build-go GO_BUILD_TAGS=${GO_BUILD_TAGS} WIRE_TAGS=${WIRE_TAGS}

-FROM ${BASE_IMAGE} as tgz-builder
+# FROM ${BASE_IMAGE} as tgz-builder

-WORKDIR /tmp/grafana
+# WORKDIR /tmp/grafana

-ARG GRAFANA_TGZ="grafana-latest.linux-x64-musl.tar.gz"
+# ARG GRAFANA_TGZ="grafana-latest.linux-x64-musl.tar.gz"

-COPY ${GRAFANA_TGZ} /tmp/grafana.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
+# # 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
@@ -171,7 +149,7 @@ 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 $GF_PATHS_HOME/public ./public
COPY --from=go-src /tmp/grafana/LICENSE ./

EXPOSE 3000
diff --git a/Makefile b/Makefile
index 25904afe..ab1b5cfe 100644
--- a/Makefile
+++ b/Makefile
@@ -230,19 +230,20 @@ 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

build-docker-full: ## Build Docker image for development.
@echo "build docker container"
tar -ch . | \
- docker buildx build - \
+ docker build - \
--platform $(PLATFORM) \
--build-arg BINGO=false \
--build-arg GO_BUILD_TAGS=$(GO_BUILD_TAGS) \
--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)

build-docker-full-ubuntu: ## Build Docker image based on Ubuntu for development.
41 changes: 41 additions & 0 deletions grafana/grafana/10.4.1/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This file is generated by the template.

REGISTRY?=lcr.loongnix.cn
ORGANIZATION?=grafana
REPOSITORY?=grafana
TAG?=10.4.1
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-support-loong64.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=lcr.loongnix.cn/library/alpine:3.19 \
--build-arg JS_IMAGE=docker.m.daocloud.io/grafana/grafana:$(TAG) \
--build-arg https_proxy=${https_proxy} --build-arg http_proxy=${http_proxy} \
--build-arg GO_IMAGE=lcr.loongnix.cn/library/golang:1.22-alpine" \
$(MAKE) -C src/$(SOURCE) build-docker-full

push:
docker push $(IMAGE)

clean:
rm -rf src

0 comments on commit 2b29174

Please sign in to comment.