Skip to content

Commit

Permalink
Merge branch '32-fix-launch-networks-ipv6' into 'master'
Browse files Browse the repository at this point in the history
Resolve #32 "Fix launch networks ipv6"

See merge request ix.ai/swarm-launcher!34
  • Loading branch information
tlex committed May 25, 2023
2 parents 02257dc + 02dc66f commit bd6c914
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -336,15 +336,14 @@ xEOF
if [ -n "${LAUNCH_EXT_NETWORKS_IPV6}" ]; then
read -ra ARR <<<"${LAUNCH_EXT_NETWORKS_IPV6}"
for NETWORK in "${ARR[@]}"; do
IFS=':' read -r NETWORK IPV6 <<< "${NETWORK}"
IFS='-' read -r NETWORK IPV6 <<< "${NETWORK}"
{
echo " ${NETWORK}:"
echo " ipv6_address: '${IPV6}'"
} >> "${COMPOSE_FILE}"
done
fi
# LAUNCH_EXT_NETWORKS_MIXED are existing attachable networks, where the IP is manually assigned
# This assumes both IPv4 and IPv6 addresses are manually assigned
# LAUNCH_EXT_NETWORKS_MIXED are existing attachable networks, where the IPV4 and IPV6 is manually assigned
# The format is `network1-ipv4-ipv6 network2-ipv4-ipv6 ... networkN-ipv4-ipv6`
if [ -n "${LAUNCH_EXT_NETWORKS_MIXED}" ]; then
read -ra ARR <<<"${LAUNCH_EXT_NETWORKS_MIXED}"
Expand All @@ -357,6 +356,7 @@ xEOF
} >> "${COMPOSE_FILE}"
done
fi
# Here starts the `networks` section
echo "networks:" >> "${COMPOSE_FILE}"
for NETWORK in ${LAUNCH_NETWORKS}; do
{
Expand All @@ -381,6 +381,26 @@ xEOF
} >> "${COMPOSE_FILE}"
done
fi
if [ -n "${LAUNCH_EXT_NETWORKS_IPV6}" ]; then
read -ra ARR <<<"${LAUNCH_EXT_NETWORKS_IPV6}"
for NETWORK in "${ARR[@]}"; do
IFS='-' read -r NETWORK IPV6 <<< "${NETWORK}"
{
echo " ${NETWORK}:";
echo " external: true";
} >> "${COMPOSE_FILE}"
done
fi
if [ -n "${LAUNCH_EXT_NETWORKS_MIXED}" ]; then
read -ra ARR <<<"${LAUNCH_EXT_NETWORKS_MIXED}"
for NETWORK in "${ARR[@]}"; do
IFS='-' read -r NETWORK IPV4 IPV6 <<< "${NETWORK}"
{
echo " ${NETWORK}:";
echo " external: true";
} >> "${COMPOSE_FILE}"
done
fi
fi
fi
fi
Expand Down Expand Up @@ -431,9 +451,7 @@ COMMAND=(
[[ -n "${LAUNCH_ARG_ENVFILE}" ]] && COMMAND=(--env-file "${LAUNCH_ARG_ENVFILE}" "${COMMAND[@]}")

# Here is the container started
docker compose "${COMMAND[@]}" &
docker compose "${COMMAND[@]}" & wait $!

child=$!
wait "$child"
_cleanup

0 comments on commit bd6c914

Please sign in to comment.