mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-18 17:01:07 +00:00
Add docker-standard ftp_proxy/FTP_PROXY env var, and socks-standard all_proxy/ALL_PROXY
Signed-off-by: Avi Deitcher <avi@deitcher.net>
This commit is contained in:
parent
d9bdd77ba7
commit
fad3354448
@ -151,3 +151,27 @@ linuxkit pkg build -org=wombat -disable-content-trust -hash=foo push
|
||||
|
||||
and this will create `wombat/<image>:foo-<arch>` and
|
||||
`wombat/<image>:foo` for use in your YAML files.
|
||||
|
||||
### Proxies
|
||||
|
||||
If you are building packages from behind a proxy, `linuxkit pkg build` respects
|
||||
the following environment variables, and will set them as `--build-arg` to
|
||||
`docker build` when building a package.
|
||||
|
||||
* `http_proxy` / `HTTP_PROXY`
|
||||
* `https_proxy` / `HTTPS_PROXY`
|
||||
* `ftp_proxy` / `FTP_PROXY`
|
||||
* `no_proxy` / `NO_PROXY`
|
||||
* `all_proxy` / `ALL_PROXY`
|
||||
|
||||
Note that the first four of these are the standard built-in `build-arg` options available
|
||||
for `docker build`; see the [docker build documentation](https://docs.docker.com/v17.09/engine/reference/builder/#arg).
|
||||
The last, `all_proxy`, is a standard var used for socks proxying. Since it is not built into `docker build`,
|
||||
if you want to use it, you will need to add the following line to the dockerfile:
|
||||
|
||||
```dockerfile
|
||||
ARG all_proxy
|
||||
```
|
||||
|
||||
Linuxkit does not judge between lower-cased or upper-cased variants of these options, e.g. `http_proxy` vs `HTTP_PROXY`,
|
||||
as `docker build` does not either. It just passes them through "as-is".
|
||||
|
@ -41,13 +41,19 @@ func isExecErrNotFound(err error) bool {
|
||||
return eerr.Err == exec.ErrNotFound
|
||||
}
|
||||
|
||||
// these are the standard 4 build-args supported by `docker build`
|
||||
// plus the all_proxy/ALL_PROXY which is a socks standard one
|
||||
var proxyEnvVars = []string{
|
||||
"http_proxy",
|
||||
"https_proxy",
|
||||
"no_proxy",
|
||||
"ftp_proxy",
|
||||
"all_proxy",
|
||||
"HTTP_PROXY",
|
||||
"HTTPS_PROXY",
|
||||
"NO_PROXY",
|
||||
"FTP_PROXY",
|
||||
"ALL_PROXY",
|
||||
}
|
||||
|
||||
func (dr dockerRunner) command(args ...string) error {
|
||||
@ -72,7 +78,12 @@ func (dr dockerRunner) command(args ...string) error {
|
||||
[]string{"--build-arg", fmt.Sprintf("%s=%s", proxyVarName, value)}...)
|
||||
}
|
||||
}
|
||||
cmd.Args = append(append(cmd.Args[:2], buildArgs...), cmd.Args[2:]...)
|
||||
// cannot use usual append(append( because it overwrites part of it
|
||||
newArgs := make([]string, len(cmd.Args)+len(buildArgs))
|
||||
copy(newArgs[:2], cmd.Args[:2])
|
||||
copy(newArgs[2:], buildArgs)
|
||||
copy(newArgs[2+len(buildArgs):], cmd.Args[2:])
|
||||
cmd.Args = newArgs
|
||||
|
||||
if dr.ctx != nil {
|
||||
stdin, err := cmd.StdinPipe()
|
||||
|
Loading…
Reference in New Issue
Block a user