Spaces:
Running
Running
souliya_pps commited on
Commit ·
4cc5ece
1
Parent(s): 634de84
Move DB decompression to entrypoint (runtime) to fix Docker build OOM on HF
Browse files- Dockerfile +0 -4
- entrypoint.sh +11 -0
Dockerfile
CHANGED
|
@@ -31,10 +31,6 @@ RUN composer install --no-dev --optimize-autoloader --no-interaction
|
|
| 31 |
COPY . .
|
| 32 |
|
| 33 |
RUN mkdir -p storage/cache/sqlite storage/tmp storage/tts && chmod -R 777 storage
|
| 34 |
-
RUN for f in databases/*.sqlite.gz; do \
|
| 35 |
-
code=$(basename "$f" .sqlite.gz); \
|
| 36 |
-
php -d memory_limit=256M -r "file_put_contents('storage/cache/sqlite/${code}.sqlite', gzdecode(file_get_contents('databases/${code}.sqlite.gz')));"; \
|
| 37 |
-
done
|
| 38 |
|
| 39 |
COPY entrypoint.sh /entrypoint.sh
|
| 40 |
RUN chmod +x /entrypoint.sh
|
|
|
|
| 31 |
COPY . .
|
| 32 |
|
| 33 |
RUN mkdir -p storage/cache/sqlite storage/tmp storage/tts && chmod -R 777 storage
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
COPY entrypoint.sh /entrypoint.sh
|
| 36 |
RUN chmod +x /entrypoint.sh
|
entrypoint.sh
CHANGED
|
@@ -4,4 +4,15 @@ set -e
|
|
| 4 |
# Overwrite .env from environment variables so the app's custom loader picks them up
|
| 5 |
env > /var/www/html/.env
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
exec apache2-foreground
|
|
|
|
| 4 |
# Overwrite .env from environment variables so the app's custom loader picks them up
|
| 5 |
env > /var/www/html/.env
|
| 6 |
|
| 7 |
+
# Decompress SQLite databases on first boot
|
| 8 |
+
if [ -n "$(ls /var/www/html/databases/*.sqlite.gz 2>/dev/null)" ]; then
|
| 9 |
+
for f in /var/www/html/databases/*.sqlite.gz; do
|
| 10 |
+
code=$(basename "$f" .sqlite.gz)
|
| 11 |
+
target="/var/www/html/storage/cache/sqlite/${code}.sqlite"
|
| 12 |
+
if [ ! -f "$target" ]; then
|
| 13 |
+
php -d memory_limit=512M -r "file_put_contents('$target', gzdecode(file_get_contents('$f')));"
|
| 14 |
+
fi
|
| 15 |
+
done
|
| 16 |
+
fi
|
| 17 |
+
|
| 18 |
exec apache2-foreground
|