Docker 两阶段构建部署 Golang 应用

golang:alpine 是一个超小 Golang 发行版

sudo mkdir -p /etc/systemd/system/docker.service.d sudo touch /etc/systemd/system/docker.service.d/proxy.conf

[Service]
Environment="HTTP_PROXY=http://proxy.example.com:8080/"
Environment="HTTPS_PROXY=http://proxy.example.com:8080/"
Environment="NO_PROXY=localhost,127.0.0.1,.example.com"
docker build -t go/zgateway:v0.1 .
    --build-arg "HTTP_PROXY=http://192.168.49.1:7890/" \
    --build-arg "HTTPS_PROXY=http://192.168.49.1:7890/" \
    --build-arg "http_proxy=http://192.168.49.1:7890/" \
    --build-arg "https_proxy=http://192.168.49.1:7890/" \
    --build-arg "NO_PROXY=localhost,127.0.0.1,.example.com"