From d67d25963d042556b3f752434b8d7eed0555337d Mon Sep 17 00:00:00 2001 From: nessi Date: Wed, 18 Mar 2026 09:09:52 +0100 Subject: [PATCH] feat: enable host network access during Docker build stages for dependency downloads Add BuildKit syntax directive and --network=host flag to npm install, go mod operations, and apk package installation to allow direct host network access during builds, bypassing Docker's default bridge network for improved reliability and performance of dependency downloads. --- admin-web/Dockerfile | 3 ++- backend/Dockerfile | 5 +++-- deploy/gateway/Dockerfile | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/admin-web/Dockerfile b/admin-web/Dockerfile index a5620f3..2524a72 100644 --- a/admin-web/Dockerfile +++ b/admin-web/Dockerfile @@ -1,7 +1,8 @@ +## syntax=docker/dockerfile:1.4 FROM node:22-alpine AS builder WORKDIR /app COPY package.json ./ -RUN npm install +RUN --network=host npm install COPY . . RUN npm run build diff --git a/backend/Dockerfile b/backend/Dockerfile index 7c6f9f7..b99d74d 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,10 +1,11 @@ +## syntax=docker/dockerfile:1.4 FROM golang:1.23-alpine AS builder WORKDIR /src COPY go.mod ./ COPY go.sum* ./ COPY . . -RUN go mod tidy -RUN go mod download +RUN --network=host go mod tidy +RUN --network=host go mod download RUN CGO_ENABLED=0 GOOS=linux go build -o /out/nexavpn-api ./cmd/api FROM alpine:3.21 diff --git a/deploy/gateway/Dockerfile b/deploy/gateway/Dockerfile index c3e0393..4a5ca5c 100644 --- a/deploy/gateway/Dockerfile +++ b/deploy/gateway/Dockerfile @@ -1,6 +1,7 @@ +## syntax=docker/dockerfile:1.4 FROM alpine:3.21 -RUN set -eux; \ +RUN --network=host set -eux; \ printf '%s\n' \ 'https://dl-cdn.alpinelinux.org/alpine/v3.21/main' \ 'https://dl-cdn.alpinelinux.org/alpine/v3.21/community' \