Could not connect to debian.map.fastlydns.net:80 (199.232.22.132), connection timed out Unable to connect to deb.debian.org:http:

DockerFile

FROM node:16

Install sqlite3 dependencies. You can skip this if you don’t use sqlite3 in the image,

in which case you should also move better-sqlite3 to “devDependencies” in package.json.

RUN --mount=type=cache,target=/var/cache/apt,sharing=locked
–mount=type=cache,target=/var/lib/apt,sharing=locked
apt-get update &&
apt-get install -y --no-install-recommends libsqlite3-dev python3 build-essential &&
yarn config set python /usr/bin/python3

From here on we use the least-privileged node user to run the backend.

USER node

This should create the app dir as node.

If it is instead created as root then the tar command below will fail: can't create directory 'packages/': Permission denied.

If this occurs, then ensure BuildKit is enabled (DOCKER_BUILDKIT=1) so the app dir is correctly created as node.

WORKDIR /app

This switches many Node.js dependencies to production mode.

ENV NODE_ENV production

Copy repo skeleton first, to avoid unnecessary docker cache invalidation.

The skeleton contains the package.json of each package in the monorepo,

and along with yarn.lock and the root package.json, that’s enough to run yarn install.

COPY --chown=node:node yarn.lock package.json packages/backend/dist/skeleton.tar.gz ./
RUN tar xzf skeleton.tar.gz && rm skeleton.tar.gz

RUN --mount=type=cache,target=/home/node/.cache/yarn,sharing=locked,uid=1000,gid=1000
yarn install --frozen-lockfile --production --network-timeout 300000

Then copy the rest of the backend bundle, along with any other files we might want.

COPY --chown=node:node packages/backend/dist/bundle.tar.gz app-config*.yaml ./
RUN tar xzf bundle.tar.gz && rm bundle.tar.gz

CMD [“node”, “packages/backend”, “–config”, “app-config.yaml”]

Error:

[stage-0 2/8] RUN --mount=type=cache,target=/var/cache/apt,sharing=locked --mount=type=cache,target=/var/lib/apt,sharing=locked apt-get update && apt-get install -y --no-install-recommends libsqlite3-dev python3 build-essential && yarn config set python /usr/bin/python3:
#6 31.04 Err:1 Index of /debian buster InRelease
#6 31.04 Could not connect to debian.map.fastlydns.net:80 (199.232.22.132), connection timed out Unable to connect to deb.debian.org:http:
#6 31.04 Err:2 Index of /debian-security buster/updates InRelease
#6 31.04 Unable to connect to deb.debian.org:http:
#6 31.04 Err:3 Index of /debian buster-updates InRelease
#6 31.04 Unable to connect to deb.debian.org:http:
#6 31.05 Reading package lists…
#6 31.07 W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease Could not connect to debian.map.fastlydns.net:80 (199.232.22.132), connection timed out Unable to connect to deb.debian.org:http:
#6 31.07 W: Failed to fetch http://deb.debian.org/debian-security/dists/buster/updates/InRelease Unable to connect to deb.debian.org:http:
#6 31.07 W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease Unable to connect to deb.debian.org:http:
#6 31.07 W: Some index files failed to download. They have been ignored, or old ones used instead.
#6 31.08 Reading package lists…
#6 31.09 Building dependency tree…
#6 31.10 Package build-essential is not available, but is referred to by another package.
#6 31.10 This may mean that the package is missing, has been obsoleted, or
#6 31.10 is only available from another source
#6 31.10
#6 31.10 E: Package ‘build-essential’ has no installation candidate

executor failed running [/bin/sh -c apt-get update && apt-get install -y --no-install-recommends libsqlite3-dev python3 build-essential && yarn config set python /usr/bin/python3]: exit code: 100

Please help me to resolve the issue