forked from thewca/worldcubeassociation.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.dev.sh
executable file
·34 lines (25 loc) · 1016 Bytes
/
entrypoint.dev.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
# Get the installed Ruby version from the runtime
RUBY_VERSION=$(ruby -e 'puts RUBY_VERSION')
# Set the versioned bundle path based on the Ruby version
BUNDLE_PATH="/usr/local/bundle/${RUBY_VERSION}"
# Create the versioned directory if it doesn't exist
mkdir -p "$BUNDLE_PATH"
CURRENT_SYMLINK="/usr/local/bundle/current"
# Check if the 'current' symlink exists
if [ -L "$CURRENT_SYMLINK" ]; then
# Read the target of the 'current' symlink
CURRENT_TARGET=$(readlink "$CURRENT_SYMLINK")
# If the target doesn't match the current Ruby version, remove the old target
if [[ "$CURRENT_TARGET" != "$BUNDLE_PATH" ]]; then
echo "Removing gems for old Ruby version: $CURRENT_TARGET"
rm -rf "$CURRENT_TARGET"
fi
fi
# Symlink the versioned directory to a common 'current' path
ln -sfn "$BUNDLE_PATH" "$CURRENT_SYMLINK"
BUNDLE_PATH="$CURRENT_SYMLINK"
# Set the BUNDLE_PATH to the symlink for all processes
export BUNDLE_PATH
# Run the main command (e.g., rails server or sidekiq)
exec "$@"