kopia lustrzana https://github.com/jupyterhub/repo2docker
Add entrypoint script which automatically propagates *_PROXY env vars to docker config
rodzic
b464a5e400
commit
e04a14a7cc
|
@ -30,5 +30,10 @@ RUN pip3 install --no-cache-dir /tmp/wheelhouse/*.whl \
|
||||||
COPY ./docker/git-credential-env /usr/local/bin/git-credential-env
|
COPY ./docker/git-credential-env /usr/local/bin/git-credential-env
|
||||||
RUN git config --system credential.helper env
|
RUN git config --system credential.helper env
|
||||||
|
|
||||||
|
# add entrypoint
|
||||||
|
COPY ./docker/entrypoint /usr/local/bin/entrypoint
|
||||||
|
RUN chmod +x /usr/local/bin/entrypoint
|
||||||
|
ENTRYPOINT ["/usr/local/bin/entrypoint"]
|
||||||
|
|
||||||
# Used for testing purpose in ports.py
|
# Used for testing purpose in ports.py
|
||||||
EXPOSE 52000
|
EXPOSE 52000
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
function write_config() {
|
||||||
|
# Checks for the environment variables *_PROXY.
|
||||||
|
# If at least one variables is found, it writes all found variables
|
||||||
|
# into a docker config file
|
||||||
|
docker_cfg="$1"
|
||||||
|
httpProxy="${HTTP_PROXY:-$http_proxy}"
|
||||||
|
httpsProxy="${HTTPS_PROXY:-$https_proxy}"
|
||||||
|
noProxy="${NO_PROXY:-$no_proxy}"
|
||||||
|
# If no proxy vars are set, do nothing
|
||||||
|
[ -z "$httpProxy" ] && [ -z "$httpsProxy" ] && [ -z "$noProxy" ] && return
|
||||||
|
[ -f "$1" ] && echo "$1 already exists. Not touching it. You are responsible for setting your proxy vars there yourself" >&2 && return
|
||||||
|
sep=""
|
||||||
|
mkdir -p "$(dirname $docker_cfg)"
|
||||||
|
cat <<EOF > "$docker_cfg"
|
||||||
|
{
|
||||||
|
"proxies": {
|
||||||
|
"default": {
|
||||||
|
EOF
|
||||||
|
[ -n "$httpProxy" ] && echo -ne "$sep"' "httpProxy": "'"$httpProxy"'"' >> "$docker_cfg" && sep=",\n"
|
||||||
|
[ -n "$httpsProxy" ] && echo -ne "$sep"' "httpsProxy": "'"$httpsProxy"'"' >> "$docker_cfg" && sep=",\n"
|
||||||
|
[ -n "$noProxy" ] && echo -ne "$sep"' "noProxy": "'"$noProxy"'"' >> "$docker_cfg" && sep=",\n"
|
||||||
|
cat <<EOF >> "$docker_cfg"
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
write_config /root/.docker/config.json
|
||||||
|
|
||||||
|
exec "$@"
|
Ładowanie…
Reference in New Issue