diff --git a/entrypoint.sh b/entrypoint.sh index 1c9695a..b52fcb7 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,13 @@ #!/bin/sh set -e -mkdir -p /app/data /app/assets/deck-images -[ -f /app/data/colony.json ] || echo '{"games":[]}' > /app/data/colony.json -[ -f /app/data/decks.json ] || echo '{"decks":[]}' > /app/data/decks.json + +mkdir -p /app/data /app/data/deck-images + +# Docker creates directories instead of files when a bind-mount target doesn't exist. +# Remove them so we can create proper JSON files. +for f in /app/data/colony.json /app/data/decks.json; do + [ -d "$f" ] && rm -rf "$f" + [ -f "$f" ] || echo '{}' > "$f" +done + exec node server.js