dockernpmddev

ddev start - "Building project images" takes forever, how can I see what it's doing?


I have a project, which is using ddev for a local development environment, to run a headless website. Running ddev start takes about 2 hours on my machine, but not for my colleagues, and I would like to find some way to debug why that is. It just runs

Building project images....................................

...and so on. As an aside, I've long suspected that ddev/docker might have some networking issue on my machine, but have never gotten to the bottom of it. But this is just a suspicion, based on the fact that occasionally, when I've had my machine running for a while, I will get random freezes, with several error pop ups saying:

"Filesystem not responding: Filesystem mounted at /var/lib/docker/overlay2/{some hash}/merged' is not responding."

I am running Ubuntu 20.04.

But that may be a separate issue entirely. When I run into that, I just do a restart, and it goes away for a while. What I am asking here is:

How can I get ddev/docker to display what it is actually doing instead of just a series of dots for "Building project images..."?

I've tried the suggestions made here https://stackoverflow.com/a/69500575/7948774, but it doesn't seem to make any difference. Also, I don't see anything in the ddev logs that points to the cause.

I suspect it is related to the fact that this project has two Dockerfiles, each copies the package files, and runs their own npm ci commands. I'm no docker expert, but my understanding is that it caches the result of every command made in a Dockerfile, so perhaps running npm install this way is too onerous?

So then part 2 of this question is, if I confirm it's these npm install commands taking forever, what can I do about those? An example of what it's doing is:

# Copy package manifests and install
COPY package*.json ./
RUN if test -e package-lock.json; then npm ci; else npm i; fi

# Copy build configuration
COPY tsconfig.json next.config.js ambient.d.ts ./

CMD ["/app/node_modules/.bin/concurrently", "npm run dev"]

EXPOSE 3000

Solution

  • To se what's going during the build stage in ddev start use ddev debug rebuild - that will show you everything that happens in your webimage_extra_packages and custom .ddev/web-build/Dockerfile.*

    The docs mention this but don't note the need that you have, but it's great for that.

    Note that if things are working right, the DDEV build stage only does its work once the first time you ddev start a project (or when you change webimage_extra_packages or your Dockerfiles.

    To see the consolidated build Dockerfile, you may want to inspect .ddev/.webimageBuild/Dockerfile so you can see the sum of your instructions. (This isn't something you edit, it's what DDEV uses after consolidating all your instructions.)

    For the second part of your question, about making npm run faster, you'll need to ask elsewhere, it's not a DDEV question.