Docker image taking 5 minutes to run a container

I have the following Dockerfile:

FROM golang:1.9 AS build-go
RUN go get; exit 0
RUN go run build.go setup && go run build.go build

FROM node:8 AS build-node
COPY --from=build-go $HOME/go/src/ .
RUN npm install -g yarn && yarn install --pure-lockfile
CMD npm run build && ./bin/linux-amd64/grafana-server

When I use this file to create and build an image then use that to start a container it takes ages for it to finish the npm run build command. This causes the server to run after a total of 5 minutes.

Isn’t there anything that can be done to speed up the npm run build process?

BTW: Why do you need to build a Docker image before running a container? Why you can’t just pull ready image from the private/public repo? Your approach doesn’t look like a good practice.

The front end build takes time a long asset minification and optimization is time consuming. But we are looking at ways to optimize it further (down to around 2-3 minutes )

Im going to fork the grafana repo, make some changes and then create a docker image.

What could be a possible workaround for now?