Skip to content

Instantly share code, notes, and snippets.

@oprietop
Created January 15, 2023 11:35
Show Gist options
  • Save oprietop/38708353bddd1a5b21767aac93e2f5b6 to your computer and use it in GitHub Desktop.
Save oprietop/38708353bddd1a5b21767aac93e2f5b6 to your computer and use it in GitHub Desktop.
Create a docker-compose file extending all directories not beginning with _
#!/bin/sh
# Create a docker-compose file extending all directories not beginning with _
FILE=docker-compose.yml
echo 'version: "3"' > ${FILE}
echo 'services:' >> ${FILE}
for ITEM in *; do
if [ -d "${ITEM}" ]; then
if [[ ${ITEM} == _* ]]; then
echo "Skipping ${ITEM}"
continue
fi
echo "Adding ${ITEM}"
cat <<EOF >> ${FILE}
${ITEM}:
extends:
file: ${ITEM}/docker-compose.yml
service: ${ITEM}
EOF
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment