Building in Docker: `go install -v ./pkg/cmd/grafana-server` fails (cannot find packages) -- v5.2-beta1

I’m getting the following error when trying to run go run build.go setup inside my container – however, I don’t get the error when I run it outside the container.

go install -v ./pkg/cmd/grafana-server
pkg/login/ldap_settings.go:7:2: cannot find package “” in any of:
/usr/local/go/src/ (from $GOROOT)
/go/src/ (from $GOPATH)
pkg/services/notifications/codes.go:9:2: cannot find package “” in any of:
/usr/local/go/src/ (from $GOROOT)
/go/src/ (from $GOPATH)


I’m building 5.2-beta. I’ll post my Dockerfile below if it helps:

FROM golang:latest AS build

ENV SRC_DIR=/go/src/


# Basic dependencies for building
  apt-get -y update && \
  apt-get -y install git && \
  apt-get -y install ruby-full && \
  gem install fpm

# Basic dependencies for building NPM projects
  apt-get -y install --reinstall ca-certificates && \
  curl -sL | bash - && \
  apt-get -y install nodejs build-essential && \
  npm install -g npm && \
  npm config set strict-ssl=false

# Basic dependencies for building Grafana NPM project
  npm install -g yarn && \
  yarn config set "strict-ssl" false && \
  yarn install --pure-lockfile

# Building of Grafana
  npm run build && \
  go run build.go setup && \
  go run build.go build

# Create final stage containing only required artifacts
FROM golang:latest
ENV SRC_DIR=/go/src/

COPY --from=build $SRC_DIR/conf ./conf
COPY --from=build $SRC_DIR/public ./public
COPY --from=build $SRC_DIR/data/plugins ./data/plugins
COPY --from=build $SRC_DIR/bin/grafana-server ./bin/grafana-server


CMD ["./bin/grafana-server"]

slight bump on this, I’m unsure what may have changed that would cause these (previous versions of grafana built fine using the same Dockerfile). If I’m doing something woefully wrong, please let me know.

Looks like this is due to a bug in the .dockerignore file that was recently added (hence why the issue only popped up with the upgrade to v5.2-beta1); we likely want to preserve the vendor path into the container.

Pull request submitted to address the issue: