Skip to content

Commit df81a2d

Browse files
committed
migration start fixes
1 parent 1bcd95f commit df81a2d

File tree

7 files changed

+22
-10
lines changed

7 files changed

+22
-10
lines changed

Dockerfile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ ENV ENABLE_CRONTAB=1
55
ENV APP_PATH=/app
66
ENV DOCUMENT_ROOT=public
77
ENV TZ=UTC
8+
ENV ENABLE_TUNING_FPM=1
9+
ENV DISABLE_AUTORUN_SCRIPTS=0
810

911
# Copy application files
1012
COPY app/ ${APP_PATH}/
@@ -14,18 +16,17 @@ WORKDIR ${APP_PATH}
1416
RUN composer config platform.php-64bit 8.3 && \
1517
composer install --no-interaction --optimize-autoloader --no-dev
1618

17-
# Create autorun scripts
18-
COPY setup/ /setup/
19-
RUN mkdir -p /startup && \
20-
ln -sf /setup/start.php /startup/20-migrations.php
21-
2219
# Copy cron jobs configuration
2320
COPY crontab /etc/cron.d/lerama-cron
2421
RUN chmod 0644 /etc/cron.d/lerama-cron
2522

2623
# Copy setup script
27-
COPY docker-entrypoint.sh /startup/10-setup-env.sh
28-
RUN chmod +x /startup/10-setup-env.sh
24+
COPY /autorun/10-env /startup/10-env+
25+
RUN chmod +x /startup/10-env
26+
27+
# Copy migration script
28+
COPY /autorun/20-migration /startup/20-migration
29+
RUN chmod +x /startup/20-migration
2930

3031
# Set permissions
3132
RUN chown -R www-data:www-data ${APP_PATH} && \
File renamed without changes.
File renamed without changes.
File renamed without changes.

setup/start.php renamed to app/setup/migration.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,14 @@ function executeSqlFile($conn, $filePath, $migrationName = null) {
137137

138138
echo "Connected to database successfully" . PHP_EOL;
139139

140-
// Check if base tables exist, if not run schema.sql
140+
// Check if base tables exist, if not run migration-initial.sql
141141
$feedsTableExists = tableExists($conn, 'feeds');
142142
$feedItemsTableExists = tableExists($conn, 'feed_items');
143143

144144
if (!$feedsTableExists || !$feedItemsTableExists) {
145-
echo "Database tables do not exist. Running schema.sql..." . PHP_EOL;
145+
echo "Database tables do not exist. Running migration-initial.sql..." . PHP_EOL;
146146

147-
$schemaFile = __DIR__ . '/schema.sql';
147+
$schemaFile = __DIR__ . '/migration-initial.sql';
148148
if (!file_exists($schemaFile)) {
149149
throw new Exception("Schema file not found: {$schemaFile}");
150150
}
File renamed without changes.

autorun/20-migration

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
echo "Running database migrations..."
4+
php /app/setup/migration.php
5+
6+
if [ $? -eq 0 ]; then
7+
echo "Database migrations completed successfully"
8+
else
9+
echo "Database migrations failed"
10+
exit 1
11+
fi

0 commit comments

Comments
 (0)