add proxy to build images
Some checks failed
Build and Push to ACR / docker (push) Failing after 5m45s
Some checks failed
Build and Push to ACR / docker (push) Failing after 5m45s
This commit is contained in:
@@ -51,17 +51,27 @@ jobs:
|
||||
echo "$ACR_PASSWORD" | docker login "$ACR_REGISTRY" \
|
||||
--username "$ACR_USERNAME" --password-stdin
|
||||
|
||||
- name: Build Docker Image
|
||||
- name: Ensure proxy_net exists
|
||||
run: docker network inspect proxy_net >/dev/null 2>&1 || docker network create proxy_net
|
||||
|
||||
- name: Create buildx builder on proxy_net
|
||||
run: |
|
||||
docker buildx rm ci-builder >/dev/null 2>&1 || true
|
||||
docker buildx create \
|
||||
--name ci-builder --use \
|
||||
--driver docker-container \
|
||||
--driver-opt network=proxy_net \
|
||||
--driver-opt env.http_proxy=http://proxy:7890,env.https_proxy=http://proxy:7890
|
||||
|
||||
- name: Build Docker Image (via proxy)
|
||||
env:
|
||||
IMAGE: ${{ secrets.ACR_REGISTRY }}/${{ secrets.ACR_NAMESPACE }}/${{ vars.IMAGE_NAME }}
|
||||
TAG: ${{ steps.meta.outputs.tag }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
echo "Building ${IMAGE}:${TAG}"
|
||||
|
||||
# 确保构建时使用 proxy_net,并把代理传给 RUN 阶段
|
||||
docker build \
|
||||
--network=proxy_net \
|
||||
docker buildx build \
|
||||
--builder ci-builder \
|
||||
--progress=plain \
|
||||
--build-arg HTTP_PROXY=http://proxy:7890 \
|
||||
--build-arg HTTPS_PROXY=http://proxy:7890 \
|
||||
--build-arg NO_PROXY=localhost,127.0.0.1,proxy \
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM debian:12-slim
|
||||
ARG HTTP_PROXY
|
||||
ARG HTTPS_PROXY
|
||||
ARG NO_PROXY
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
|
||||
Reference in New Issue
Block a user