Skip to content

Commit

Permalink
Make changes required to use SQLite (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethyoo authored Oct 27, 2024
1 parent 9453a90 commit 0eb14d7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ RUN apk add --no-cache \
php82-dom \
php82-pdo_mysql \
php82-pdo_pgsql \
php82-pdo_sqlite \
php82-tokenizer
RUN ln -s /usr/bin/php82 /usr/bin/php

Expand Down Expand Up @@ -137,4 +138,4 @@ COPY --chmod=755 docker/docker-entrypoint.d/ /docker-entrypoint.d/
ENV DB_CONNECTION=sqlite

ENTRYPOINT ["/docker-entrypoint.d/start.sh"]
CMD ["run"]
CMD ["run"]
44 changes: 24 additions & 20 deletions docker/docker-entrypoint.d/start.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
#!/bin/sh

while true; do
# Check if $DB_HOST is a Unix socket (starts with "/")
if echo "$DB_HOST" | grep -q "^/"; then
# Unix socket connection
if [ -S "$DB_HOST" ]; then
echo "Successfully connected to DB via Unix socket: $DB_HOST"
break
if [ "$DB_CONNECTION" == "sqlite" ]; then
echo "Using a SQLite database"
else
while true; do
# Check if $DB_HOST is a Unix socket (starts with "/")
if echo "$DB_HOST" | grep -q "^/"; then
# Unix socket connection
if [ -S "$DB_HOST" ]; then
echo "Successfully connected to DB via Unix socket: $DB_HOST"
break
else
echo "Failed to connect to DB via Unix socket: $DB_HOST. Retrying in 10 seconds..."
fi
else
echo "Failed to connect to DB via Unix socket: $DB_HOST. Retrying in 10 seconds..."
# TCP connection
if nc -z -w 5 $DB_HOST $DB_PORT; then
echo "Successfully connected to DB via TCP: $DB_HOST:$DB_PORT"
break
else
echo "Failed to connect to DB via TCP: $DB_HOST:$DB_PORT. Retrying in 10 seconds..."
fi
fi
else
# TCP connection
if nc -z -w 5 $DB_HOST $DB_PORT; then
echo "Successfully connected to DB via TCP: $DB_HOST:$DB_PORT"
break
else
echo "Failed to connect to DB via TCP: $DB_HOST:$DB_PORT. Retrying in 10 seconds..."
fi
fi

# Wait before retrying
sleep 10
done
# Wait before retrying
sleep 10
done
fi

php /var/www/html/artisan migrate --isolated --force
php /var/www/html/artisan config:clear
Expand Down

0 comments on commit 0eb14d7

Please sign in to comment.