Skip to content

Commit

Permalink
feat: replace ip routing for host.docker.internal with native support
Browse files Browse the repository at this point in the history
  • Loading branch information
andytson-inviqa committed Mar 22, 2024
1 parent b0a2074 commit 516c147
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 24 deletions.
4 changes: 4 additions & 0 deletions _twig/docker-compose.yml/service/app.yml.twig
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ services:
{% else %}
target: nginx
image: {{ @('services.app.image') }}
{% endif %}
{% if @('host.os') == 'linux' %}
extra_hosts:
- "host.docker.internal:host-gateway"
{% endif %}
labels:
- traefik.backend={{ @('workspace.name') }}
Expand Down
5 changes: 0 additions & 5 deletions docker/image/app/Dockerfile.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
FROM console as node
COPY .my127ws/docker/image/app/root-node /

RUN apt-get update && apt-get install --no-install-recommends -y iproute2 \
&& apt-get auto-remove -qq -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

FROM {{ @('services.app.build.from.nginx') }} as nginx

RUN apk add --no-cache jq
Expand Down
19 changes: 0 additions & 19 deletions docker/image/app/root-node/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
#!/bin/bash

setup_app_networking()
{
# make linux consistent with docker-for-mac
if [ "${HOST_OS_FAMILY}" = "linux" ]; then
DOCKER_INTERNAL_HOST="host.docker.internal"
if ! grep $DOCKER_INTERNAL_HOST /etc/hosts > /dev/null ; then
DOCKER_INTERNAL_IP=$(/usr/sbin/ip route|awk '/default/ { print $3 }')
echo -e "$DOCKER_INTERNAL_IP $DOCKER_INTERNAL_HOST" | tee -a /etc/hosts > /dev/null
fi
fi
}

bootstrap()
{
setup_app_networking
}

bootstrap

if [ "${1:-}" == "sleep" ]; then
"$@"
else
Expand Down

0 comments on commit 516c147

Please sign in to comment.