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

Fix entry_point.sh docker backward compatibility problem #2728

Merged
merged 2 commits into from
Sep 28, 2024
Merged
Changes from all 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
46 changes: 29 additions & 17 deletions bin/entry_point.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
#!/bin/bash

CONFIG_FILE=_config.yml

/bin/bash -c "git restore Gemfile.lock && exec jekyll serve --watch --port=8080 --host=0.0.0.0 --livereload --verbose --trace --force_polling"&
CONFIG_FILE=_config.yml

# Function to manage Gemfile.lock
manage_gemfile_lock() {
git config --global --add safe.directory '*'
if command -v git &> /dev/null && [ -f Gemfile.lock ]; then
if git ls-files --error-unmatch Gemfile.lock &> /dev/null; then
echo "Gemfile.lock is tracked by git, keeping it intact"
git restore Gemfile.lock 2>/dev/null || true
else
echo "Gemfile.lock is not tracked by git, removing it"
rm Gemfile.lock
fi
fi
}

start_jekyll() {
manage_gemfile_lock
exec jekyll serve --watch --port=8080 --host=0.0.0.0 --livereload --verbose --trace --force_polling &
}

start_jekyll

while true; do

inotifywait -q -e modify,move,create,delete $CONFIG_FILE

if [ $? -eq 0 ]; then

echo "Change detected to $CONFIG_FILE, restarting Jekyll"

jekyll_pid=$(pgrep -f jekyll)
kill -KILL $jekyll_pid

/bin/bash -c "git restore Gemfile.lock && exec jekyll serve --watch --port=8080 --host=0.0.0.0 --livereload --verbose --trace --force_polling"&

fi

inotifywait -q -e modify,move,create,delete $CONFIG_FILE
if [ $? -eq 0 ]; then
echo "Change detected to $CONFIG_FILE, restarting Jekyll"
jekyll_pid=$(pgrep -f jekyll)
kill -KILL $jekyll_pid
start_jekyll
fi
done