Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added proxy into docker-in-docker config #56

Merged
merged 3 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .devcontainer/scripts/configure-proxies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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="{}"
DOCKER_CONFIG_FOLDER=/home/${USERNAME}/.docker
mkdir -p $DOCKER_CONFIG_FOLDER
DOCKER_CONFIG_FILE=${DOCKER_CONFIG_FOLDER}/config.json
echo $DOCKER_CONFIG_FILE
dennismeister93 marked this conversation as resolved.
Show resolved Hide resolved
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
3 changes: 2 additions & 1 deletion Dockerfiles/base/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down
Loading