diff --git a/.devcontainer/scripts/configure-proxies.sh b/.devcontainer/scripts/configure-proxies.sh index d5e037c..6c38fd6 100755 --- a/.devcontainer/scripts/configure-proxies.sh +++ b/.devcontainer/scripts/configure-proxies.sh @@ -85,6 +85,7 @@ if [ "${USE_PROXIES}" = "true" ]; then git config --global https.proxy ${HTTPS_PROXY} fi + # Apply wget proxy echo "# Proxy settings" >> /etc/wgetrc echo "http_proxy=${HTTP_PROXY}" >> /etc/wgetrc echo "https_proxy=${HTTPS_PROXY}" >> /etc/wgetrc @@ -95,6 +96,20 @@ if [ "${USE_PROXIES}" = "true" ]; then # enable root user to "apt-get" via proxy echo "Acquire::http::proxy \"${HTTP_PROXY}\";" >> /etc/apt/apt.conf echo "Acquire::https::proxy \"${HTTPS_PROXY}\";" >> /etc/apt/apt.conf + + # apply proxy for docker config + DOCKER_CONFIG_INITIAL_CONTENT="{}" + DOCKER_CONFIG_FOLDER=/home/${USERNAME}/.docker + mkdir -p $DOCKER_CONFIG_FOLDER + DOCKER_CONFIG_FILE=${DOCKER_CONFIG_FOLDER}/config.json + if [ -s "${DOCKER_CONFIG_FILE}" ]; then + echo "Existing docker config file found!" + DOCKER_CONFIG_INITIAL_CONTENT=$(cat "${DOCKER_CONFIG_FILE}") + fi + + DOCKER_PROXY_JSON="{\"default\": {\"httpProxy\": \"$HTTP_PROXY\", \"httpsProxy\": \"$HTTP_PROXY\", \"noProxy\": \"$NO_PROXY\"}}" + + echo $DOCKER_CONFIG_INITIAL_CONTENT | jq --argjson proxy "$DOCKER_PROXY_JSON" '. + {proxies: $proxy}' >| $DOCKER_CONFIG_FILE fi exit 0 diff --git a/Dockerfiles/base/.devcontainer/Dockerfile b/Dockerfiles/base/.devcontainer/Dockerfile index 8414ada..1553d3e 100644 --- a/Dockerfiles/base/.devcontainer/Dockerfile +++ b/Dockerfiles/base/.devcontainer/Dockerfile @@ -27,7 +27,8 @@ RUN groupadd --gid $USER_GID $USERNAME \ && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ && chmod 0440 /etc/sudoers.d/$USERNAME -WORKDIR /home/vscode +WORKDIR /home/${USERNAME} +# Will be available in container under home directory COPY .devcontainer/scripts/configure-proxies.sh . WORKDIR /tmp/setup COPY ./common .