From 8a6b55c6807e3badd0caf92bcd61ef75e7ef3626 Mon Sep 17 00:00:00 2001 From: kse3hi Date: Thu, 26 Oct 2023 11:52:48 +0000 Subject: [PATCH 1/3] Added proxy into docker-in-docker config --- .devcontainer/scripts/configure-proxies.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.devcontainer/scripts/configure-proxies.sh b/.devcontainer/scripts/configure-proxies.sh index d5e037c..9500e44 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,21 @@ 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="{}" + mkdir -p /home/${USERNAME}/.docker + CONFIG_FILE=/home/$USERNAME/.docker/config.json + echo $CONFIG_FILE + if [ -s "${CONFIG_FILE}" ]; then + echo "File exist" + DOCKER_CONFIG_INITIAL_CONTENT=$(cat "${CONFIG_FILE}") + fi + + DOCKER_PROXY_JSON="{\"default\": {\"httpProxy\": \"$HTTP_PROXY\", \"httpsProxy\": \"$HTTP_PROXY\", \"noProxy\": \"$NO_PROXY\"}}" + echo $DOCKER_PROXY_JSON + + echo $DOCKER_CONFIG_INITIAL_CONTENT | jq --argjson proxy "$DOCKER_PROXY_JSON" '. + {proxies: $proxy}' >| $CONFIG_FILE fi exit 0 From 00a68258020f71b482a025be1043a6e6677f56c7 Mon Sep 17 00:00:00 2001 From: kse3hi Date: Fri, 27 Oct 2023 09:15:51 +0000 Subject: [PATCH 2/3] Fixed review findings --- .devcontainer/scripts/configure-proxies.sh | 16 ++++++++-------- Dockerfiles/base/.devcontainer/Dockerfile | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.devcontainer/scripts/configure-proxies.sh b/.devcontainer/scripts/configure-proxies.sh index 9500e44..abbc65f 100755 --- a/.devcontainer/scripts/configure-proxies.sh +++ b/.devcontainer/scripts/configure-proxies.sh @@ -99,18 +99,18 @@ if [ "${USE_PROXIES}" = "true" ]; then # apply proxy for docker config DOCKER_CONFIG_INITIAL_CONTENT="{}" - mkdir -p /home/${USERNAME}/.docker - CONFIG_FILE=/home/$USERNAME/.docker/config.json - echo $CONFIG_FILE - if [ -s "${CONFIG_FILE}" ]; then - echo "File exist" - DOCKER_CONFIG_INITIAL_CONTENT=$(cat "${CONFIG_FILE}") + DOCKER_CONFIG_FOLDER=/home/${USERNAME}/.docker + mkdir -p $DOCKER_CONFIG_FOLDER + DOCKER_CONFIG_FILE=${DOCKER_CONFIG_FOLDER}/config.json + echo $DOCKER_CONFIG_FILE + 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_PROXY_JSON - echo $DOCKER_CONFIG_INITIAL_CONTENT | jq --argjson proxy "$DOCKER_PROXY_JSON" '. + {proxies: $proxy}' >| $CONFIG_FILE + 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 . From 7cce4b9afc35dd20b823acb5d05cc17f1327cc77 Mon Sep 17 00:00:00 2001 From: Serhii Korchynskyi Date: Thu, 2 Nov 2023 10:18:07 +0100 Subject: [PATCH 3/3] Remove unnecessary echo --- .devcontainer/scripts/configure-proxies.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/.devcontainer/scripts/configure-proxies.sh b/.devcontainer/scripts/configure-proxies.sh index abbc65f..6c38fd6 100755 --- a/.devcontainer/scripts/configure-proxies.sh +++ b/.devcontainer/scripts/configure-proxies.sh @@ -102,7 +102,6 @@ if [ "${USE_PROXIES}" = "true" ]; then DOCKER_CONFIG_FOLDER=/home/${USERNAME}/.docker mkdir -p $DOCKER_CONFIG_FOLDER DOCKER_CONFIG_FILE=${DOCKER_CONFIG_FOLDER}/config.json - echo $DOCKER_CONFIG_FILE if [ -s "${DOCKER_CONFIG_FILE}" ]; then echo "Existing docker config file found!" DOCKER_CONFIG_INITIAL_CONTENT=$(cat "${DOCKER_CONFIG_FILE}")