Cannot build docker image - npm install gets stuck, but entering the container wnd calling it seems to work

I had been building a gitea docker image from the git repo regularly last year (I know it’s not stable. but it’s a personal server and I like to build things from scratch), but for some reason it doesn’t work anymore.

$ make GITEA_CUSTOM=/home/gitea/custom/ USER=gitea USER_GID=50020 USER_UID=50020  docker

docker build --disable-content-trust=false -t gitea/gitea:latest .
Sending build context to Docker daemon  298.3MB
Step 1/23 : FROM golang@sha256:9b3ad7928626126b72b916609ad081cfb6c0149f6e60cef7fc1e9e15a0d1e973 AS build-env
 ---> dda4232b2bd5
Step 2/23 : ARG GOPROXY
 ---> Running in f62d33e978e0
Removing intermediate container f62d33e978e0
 ---> c2e2dcd86d09
Step 3/23 : ENV GOPROXY ${GOPROXY:-direct}
 ---> Running in 7ccb75ad6fdd
Removing intermediate container 7ccb75ad6fdd
 ---> c7cab54d1e55
 ---> Running in 647fe6d152e0
Removing intermediate container 647fe6d152e0
 ---> b269f8be337d
Step 5/23 : ARG TAGS="sqlite sqlite_unlock_notify"
 ---> Running in 4df05194b5d9
Removing intermediate container 4df05194b5d9
 ---> 2ec435ee4ea3
Step 6/23 : ENV TAGS "bindata $TAGS"
 ---> Running in b2a61a97c2e8
Removing intermediate container b2a61a97c2e8
 ---> 908073fc43dd
Step 7/23 : RUN apk --no-cache add build-base git nodejs npm
 ---> Running in 8e7d725abe16
(1/27) Installing libgcc (9.2.0-r4)
(2/27) Installing libstdc++ (9.2.0-r4)
(3/27) Installing binutils (2.33.1-r0)
(4/27) Installing libmagic (5.37-r1)
(5/27) Installing file (5.37-r1)
(6/27) Installing gmp (6.1.2-r1)
(7/27) Installing isl (0.18-r0)
(8/27) Installing libgomp (9.2.0-r4)
(9/27) Installing libatomic (9.2.0-r4)
(10/27) Installing mpfr4 (4.0.2-r1)
(11/27) Installing mpc1 (1.1.0-r1)
(12/27) Installing gcc (9.2.0-r4)
(13/27) Installing musl-dev (1.1.24-r2)
(14/27) Installing libc-dev (0.7.2-r0)
(15/27) Installing g++ (9.2.0-r4)
(16/27) Installing make (4.2.1-r2)
(17/27) Installing fortify-headers (1.1-r0)
(18/27) Installing build-base (0.5-r1)
(19/27) Installing nghttp2-libs (1.40.0-r0)
(20/27) Installing libcurl (7.67.0-r0)
(21/27) Installing expat (2.2.9-r1)
(22/27) Installing pcre2 (10.34-r1)
(23/27) Installing git (2.24.3-r0)
(24/27) Installing c-ares (1.15.0-r0)
(25/27) Installing libuv (1.34.0-r0)
(26/27) Installing nodejs (12.15.0-r1)
(27/27) Installing npm (12.15.0-r1)
Executing busybox-1.31.1-r9.trigger
OK: 248 MiB in 42 packages
Removing intermediate container 8e7d725abe16
 ---> f7e8c74db287
Step 8/23 : COPY . ${GOPATH}/src/
 ---> 3ada3f6d20cc
Step 9/23 : WORKDIR ${GOPATH}/src/
 ---> Running in ce6a6f39c3d8
Removing intermediate container ce6a6f39c3d8
 ---> 1e4b42288b89
Step 10/23 : RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi  && make clean-all build
 ---> Running in 0d5904e3849f
go clean -i ./...
rm -rf gitea dist modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go modules/public/bindata.go.hash modules/options/bindata.go.hash modules/templates/bindata.go.hash \
	integrations*.test \
	integrations/gitea-integration-pgsql/ integrations/gitea-integration-mysql/ integrations/gitea-integration-mysql8/ integrations/gitea-integration-sqlite/ \
	integrations/gitea-integration-mssql/ integrations/indexers-mysql/ integrations/indexers-mysql8/ integrations/indexers-pgsql integrations/indexers-sqlite \
	integrations/indexers-mssql integrations/mysql.ini integrations/mysql8.ini integrations/pgsql.ini integrations/mssql.ini
rm -rf public/js public/css public/fomantic
npm install --no-save
npm ERR! errno ETIMEDOUT
npm ERR! network request to failed, reason: connect ETIMEDOUT
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-05-12T10_05_08_951Z-debug.log
make: *** [Makefile:577: node_modules] Error 1
The command '/bin/sh -c if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi  && make clean-all build' returned a non-zero code: 2
make: *** [docker/Makefile:9: docker] Error 2

npm runs for a long time before giving up the connection.

Now, the really strange part is this: the build process runs in a docker container (recursing_lehmann in this run).
So if I go there and try to call npm,

docker exec -ti recursing_lehmann sh
/go/src/ # npm install --no-save

The command works! But this is the same container where “npm install --no-save” got stuck, not able to download anything. Of course, this doesn;t help, since the build process is still stalled.

What did I get wrong?

How can I get a docker image from the git repo?

Thanks a lot!

It appears there is some network connectivity issues with npm on your machine, I recommend trying to see if you can switch networks and/or machines and see if it that works so you can narrow down where failure happens.

As for pre-built images you can see them at: