lthn.io/Dockerfile
Claude faa0d89e8d
fix: SQLite database path in container + create on build
Container was using host path for SQLite. Now creates database.sqlite
during Docker build and sets DB_DATABASE=/app/database/database.sqlite
in compose env. Migrations run on startup via laravel-entrypoint.sh.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 11:36:08 +01:00

63 lines
2 KiB
Docker

# Host Hub - FrankenPHP Production Dockerfile
#
# The host prepares the application (composer install, npm build).
# This Dockerfile only packages the runtime image.
FROM dunglas/frankenphp:1-php8.5-trixie
# Install PHP extensions
RUN install-php-extensions \
pcntl \
pdo_mysql \
redis \
gd \
intl \
zip \
opcache \
bcmath \
exif \
sockets
# Upgrade base image packages and install system packages
RUN apt-get update && apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
redis-server supervisor curl mariadb-client \
&& rm -rf /var/lib/apt/lists/*
# Configure PHP for production
COPY --chmod=644 utils/docker/config/octane.ini $PHP_INI_DIR/conf.d/octane.ini
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
# Set working directory
WORKDIR /app
# Install composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Copy pre-built application (vendor + node_modules/public built on host)
COPY --chown=www-data:www-data --chmod=755 . .
# Clear stale caches, create SQLite DB, fix permissions
RUN rm -rf bootstrap/cache/*.php \
storage/framework/cache/data/* \
storage/framework/sessions/* \
storage/framework/views/* \
&& mkdir -p database \
&& touch database/database.sqlite \
&& chmod -R 777 storage bootstrap/cache database
# Optimise autoloader + discover packages
RUN composer dump-autoload --optimize \
&& php artisan package:discover --ansi
# Runtime scripts
COPY --chmod=755 utils/scripts/redis-entrypoint.sh /usr/local/bin/redis-entrypoint.sh
COPY --chmod=755 utils/scripts/laravel-entrypoint.sh /usr/local/bin/laravel-entrypoint.sh
COPY --chmod=644 utils/docker/config/supervisord.prod.conf /etc/supervisor/conf.d/supervisord.conf
ENV OCTANE_PORT=80
EXPOSE 80 8080 8088 6379 26379
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD curl -f http://localhost:${OCTANE_PORT}/up || exit 1
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]