I was trying to build and run Grafana v7.5.17 directly from source code for the fix of loki query input issue with Chrome. However, the issue is not fixed by this way.
Source code: Release v7.5.17 · grafana/grafana · GitHub
Fixes applied: [v7.5.x] Chore: Update slate and related packages (#54566) by kaydelaney · Pull Request #55688 · grafana/grafana · GitHub
I tried on both MacOS and Ubuntu,
the command I used on MacOS:
make build-docker-full
docker run -d -p 3000:3000 grafana/grafana:dev
The command I used on Ubuntu:
docker build --tag grafana/grafana:dev -f Dockerfile.ubuntu .
docker run -d -p 3000:3000 grafana/grafana:dev
The result I got (same on both os):
If I run the source code using commands in the developer-guide, the fix works. So I checked the source code in the running container, and found it was the v7.5.17 code with the fix in.
If I run the image from docker hub, everything works fine.
I’m wondering why local build does not solve the issue? Did I miss something? What is the recommended env for building image from the source code?
I’d appreciate it if anyone can help.
btw, there’re building errors with the original Dockerfile and Dockerfile.ubuntu from source code, I fixed it by move the “RUN go mod verify” after the “RUN go run build.go build”. This should be irrelevant with the problem I met though.
Hello @alenaw667, thanks for raising this issue.
I try to reproduce the issue and I cannot 
Could you please share the Dockerfile you use with us? Also are we sure that the image is been built without issues, and you are not using an older version that doesn’t contain the fix?
Thanks a lot.
Hi, thanks for replying. The docker file I use is Dockerfile.ubuntu showing below. The only changes are the RUN go mod verify
which is placed after go run build.go build
and the Run yarn check --verify-tree
. The build has 0 error with this docker file. (Sometimes I met the following error, every time the package is different, the build could succeed after a few tries)
> [js-builder 6/12] RUN yarn install --pure-lockfile:
#25 0.743 yarn install v1.22.5
#25 1.161 [1/5] Validating package.json...
#25 1.185 [2/5] Resolving packages...
#25 2.619 [3/5] Fetching packages...
#25 4.870 [1/4] Resolving packages...
#25 5.136 [2/4] Fetching packages...
#25 6.166 error https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz: Extracting tar content of undefined failed, the file appears to be corrupt: "ENOENT: no such file or directory, chmod '/usr/local/share/.cache/yarn/v6/npm-js-tokens-4.0.0-19203fb59991df98e3a287050d4647cdeaf32499-integrity/node_modules/js-tokens/index.js'"
#25 6.166 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
The code is download from github tag v7.5.17. I made no change to the source code, and the fixes are in it.
Chrome version I use: Version 107.0.5304.87 (Official Build) (x86_64)
FROM node:14.15.1-slim AS js-builder
WORKDIR /usr/src/app/
COPY package.json yarn.lock ./
COPY packages packages
RUN apt-get update && apt-get install -yq git
RUN yarn install --pure-lockfile
COPY tsconfig.json .eslintrc .editorconfig .browserslistrc .prettierrc.js ./
COPY public public
COPY tools tools
COPY scripts scripts
COPY emails emails
ENV NODE_ENV production
Run yarn check --verify-tree
RUN yarn build
FROM golang:1.15.1 AS go-builder
WORKDIR /src/grafana
COPY go.mod go.sum ./
COPY build.go package.json ./
COPY pkg pkg/
RUN go run build.go build
RUN go mod verify
FROM ubuntu:20.04
LABEL maintainer="Grafana team <hello@grafana.com>"
EXPOSE 3000
ARG GF_UID="472"
ARG GF_GID="472"
ENV PATH="/usr/share/grafana/bin:$PATH" \
GF_PATHS_CONFIG="/etc/grafana/grafana.ini" \
GF_PATHS_DATA="/var/lib/grafana" \
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"
WORKDIR $GF_PATHS_HOME
COPY conf conf
# curl should be part of the image
RUN apt-get update && apt-get install -y ca-certificates curl
RUN mkdir -p "$GF_PATHS_HOME/.aws" && \
addgroup --system --gid $GF_GID grafana && \
adduser --uid $GF_UID --system --ingroup grafana grafana && \
mkdir -p "$GF_PATHS_PROVISIONING/datasources" \
"$GF_PATHS_PROVISIONING/dashboards" \
"$GF_PATHS_PROVISIONING/notifiers" \
"$GF_PATHS_PROVISIONING/plugins" \
"$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:grafana "$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"
COPY --from=go-builder /src/grafana/bin/linux-amd64/grafana-server /src/grafana/bin/linux-amd64/grafana-cli bin/
COPY --from=js-builder /usr/src/app/public public
COPY --from=js-builder /usr/src/app/tools tools
COPY packaging/docker/run.sh /
USER grafana
ENTRYPOINT [ "/run.sh" ]
Hi, vendors~app.xxxxxx.js
file is the only different file from official image after local build. Replace this file with the one from official build can solve the issue. However, this is not a solution in my situation.
There should be sth wrong during the build process, because this issue can be reproduced every time for local build on Mac, Ubuntu and CentOS.
What is the right way of building source code locally? I appreciate any instructions or correctness of my build process posted before.
this is solved by add COPY patches patches
to
COPY package.json yarn.lock ./
COPY packages packages