chore: improve docker-full-build
How to use:
make build-docker-js-cache
make build-docker-full \
PLATFORM=linux/arm64 \
DOCKER_BUILD_ARGS="--build-arg JS_SRC=grafana-js-cache:latest"
This commit is contained in:
+9
-5
@@ -118,7 +118,7 @@ COPY pkg/codegen pkg/codegen
|
||||
COPY pkg/plugins/codegen pkg/plugins/codegen
|
||||
COPY apps/example apps/example
|
||||
|
||||
RUN go mod download
|
||||
RUN --mount=type=cache,target=/go/pkg/mod go mod download
|
||||
|
||||
COPY embed.go Makefile build.go package.json ./
|
||||
COPY cue.mod cue.mod
|
||||
@@ -135,7 +135,9 @@ COPY .github .github
|
||||
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 --mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
make build-go GO_BUILD_TAGS=${GO_BUILD_TAGS} WIRE_TAGS=${WIRE_TAGS}
|
||||
|
||||
# From-tarball build stage
|
||||
FROM ${BASE_IMAGE} AS tgz-builder
|
||||
@@ -168,7 +170,8 @@ ENV PATH="/usr/share/grafana/bin:$PATH" \
|
||||
GF_PATHS_HOME="/usr/share/grafana" \
|
||||
GF_PATHS_LOGS="/var/log/grafana" \
|
||||
GF_PATHS_PLUGINS="/var/lib/grafana/plugins" \
|
||||
GF_PATHS_PROVISIONING="/etc/grafana/provisioning"
|
||||
GF_PATHS_PROVISIONING="/etc/grafana/provisioning" \
|
||||
GF_UNIFIED_STORAGE_INDEX_PATH="/var/lib/grafana-search/bleve"
|
||||
|
||||
WORKDIR $GF_PATHS_HOME
|
||||
|
||||
@@ -225,13 +228,14 @@ RUN if [ ! $(getent group "$GF_GID") ]; then \
|
||||
"$GF_PATHS_PROVISIONING/plugins" \
|
||||
"$GF_PATHS_PROVISIONING/access-control" \
|
||||
"$GF_PATHS_PROVISIONING/alerting" \
|
||||
"$GF_UNIFIED_STORAGE_INDEX_PATH" \
|
||||
"$GF_PATHS_LOGS" \
|
||||
"$GF_PATHS_PLUGINS" \
|
||||
"$GF_PATHS_DATA" && \
|
||||
cp conf/sample.ini "$GF_PATHS_CONFIG" && \
|
||||
cp conf/ldap.toml /etc/grafana/ldap.toml && \
|
||||
chown -R "grafana:$GF_GID_NAME" "$GF_PATHS_DATA" "$GF_PATHS_HOME/.aws" "$GF_PATHS_LOGS" "$GF_PATHS_PLUGINS" "$GF_PATHS_PROVISIONING" && \
|
||||
chmod -R 777 "$GF_PATHS_DATA" "$GF_PATHS_HOME/.aws" "$GF_PATHS_LOGS" "$GF_PATHS_PLUGINS" "$GF_PATHS_PROVISIONING"
|
||||
chown -R "grafana:$GF_GID_NAME" "$GF_PATHS_DATA" "$GF_PATHS_HOME/.aws" "$GF_PATHS_LOGS" "$GF_PATHS_PLUGINS" "$GF_PATHS_PROVISIONING" "$GF_UNIFIED_STORAGE_INDEX_PATH" && \
|
||||
chmod -R 777 "$GF_PATHS_DATA" "$GF_PATHS_HOME/.aws" "$GF_PATHS_LOGS" "$GF_PATHS_PLUGINS" "$GF_PATHS_PROVISIONING" "$GF_UNIFIED_STORAGE_INDEX_PATH"
|
||||
|
||||
COPY --from=go-src /tmp/grafana/bin/grafana* /tmp/grafana/bin/*/grafana* ./bin/
|
||||
COPY --from=js-src /tmp/grafana/public ./public
|
||||
|
||||
@@ -135,7 +135,7 @@ i18n-extract-enterprise:
|
||||
@echo "Skipping i18n extract for Enterprise: not enabled"
|
||||
else
|
||||
i18n-extract-enterprise:
|
||||
@echo "Extracting i18n strings for Enterprise"
|
||||
@echo "Extracting i18n strings for Enterprise"
|
||||
cd public/locales/enterprise && yarn run i18next-cli extract --sync-primary
|
||||
endif
|
||||
|
||||
@@ -418,6 +418,11 @@ shellcheck: $(SH_FILES) ## Run checks for shell scripts.
|
||||
TAG_SUFFIX=$(if $(WIRE_TAGS)!=oss,-$(WIRE_TAGS))
|
||||
PLATFORM=linux/amd64
|
||||
|
||||
# JS_SRC can be set to a pre-built JS image to skip frontend build
|
||||
# Example: make build-docker-full JS_SRC=grafana-js-cache:latest
|
||||
JS_SRC ?=
|
||||
DOCKER_JS_SRC_ARG = $(if $(JS_SRC),--build-arg JS_SRC=$(JS_SRC))
|
||||
|
||||
# default to a production build for frontend
|
||||
#
|
||||
DOCKER_JS_NODE_ENV_FLAG = production
|
||||
@@ -436,13 +441,20 @@ ifeq (${NODE_ENV}, dev)
|
||||
DOCKER_JS_YARN_BUILD_FLAG = dev
|
||||
DOCKER_JS_YARN_INSTALL_FLAG =
|
||||
endif
|
||||
.PHONY: build-docker-js-cache
|
||||
build-docker-js-cache: ## Build and cache the frontend Docker image for faster subsequent builds.
|
||||
@echo "building JS cache image"
|
||||
docker buildx build . \
|
||||
--platform $(PLATFORM) \
|
||||
--target js-builder \
|
||||
--tag grafana-js-cache:latest
|
||||
|
||||
.PHONY: build-docker-full
|
||||
build-docker-full: ## Build Docker image for development.
|
||||
@echo "build docker container mode=($(DOCKER_JS_NODE_ENV_FLAG))"
|
||||
tar -ch . | \
|
||||
docker buildx build - \
|
||||
docker buildx build . \
|
||||
--platform $(PLATFORM) \
|
||||
$(DOCKER_JS_SRC_ARG) \
|
||||
--build-arg NODE_ENV=$(DOCKER_JS_NODE_ENV_FLAG) \
|
||||
--build-arg JS_NODE_ENV=$(DOCKER_JS_NODE_ENV_FLAG) \
|
||||
--build-arg JS_YARN_INSTALL_FLAG=$(DOCKER_JS_YARN_INSTALL_FLAG) \
|
||||
|
||||
Reference in New Issue
Block a user