1
0
forked from metin2/web

Added Octane/FrankenPHP support for prod Docker image

This commit is contained in:
2024-12-31 20:37:45 +02:00
parent b81cdd512f
commit ba28e1dbf8
8 changed files with 582 additions and 6 deletions

View File

@ -64,11 +64,11 @@ RUN composer install --no-ansi --no-interaction --no-plugins --no-progress --no-
RUN npm ci && npm run build
# Make the init script executable
RUN chmod +x /app/docker/init.sh
RUN chmod +x /app/docker/init-apache.sh
# Expose the API on port 80
EXPOSE 80
# Run supervisord for handling the container services
ENTRYPOINT ["/bin/sh", "-c"]
CMD ["/app/docker/init.sh"]
CMD ["/app/docker/init-apache.sh"]

View File

@ -0,0 +1,36 @@
# syntax=docker/dockerfile:1
FROM dunglas/frankenphp:php8.2-alpine
#
# Install system packages & dependencies
#
RUN apk update && apk add wget npm
# Composer
RUN wget -O composer-setup.php https://getcomposer.org/installer \
&& php composer-setup.php --install-dir=/usr/local/bin --filename=composer \
&& rm ./composer-setup.php
#
# PHP extensions
#
RUN install-php-extensions pcntl gd zip intl exif mysqli pdo pdo_mysql
# Copy the source code
WORKDIR /app
COPY . /app
# Install the dependencies
RUN composer install --no-ansi --no-interaction --no-plugins --no-progress --no-scripts --optimize-autoloader
RUN npm ci && npm run build
# Make the init script executable
RUN chmod +x /app/docker/init-frankenphp.sh
# Expose the API on port 80
EXPOSE 80
# Run supervisord for handling the container services
ENTRYPOINT ["/bin/sh", "-c"]
CMD ["/app/docker/init-frankenphp.sh"]

50
docker/init-frankenphp.sh Normal file
View File

@ -0,0 +1,50 @@
#!/bin/sh
set -e
KERNEL_VERSION=$(uname -r)
KERNEL_ARCH=$(uname -m)
FRANKENPHP_VERSION=$(frankenphp -v | cut -d " " -f 2)
PHP_VERSION=$(php -r "echo PHP_VERSION;")
echo "The Old Metin2 Project - Web management system"
echo "Kernel ${KERNEL_VERSION}, architecture: ${KERNEL_ARCH}, FrankenPHP: ${FRANKENPHP_VERSION}, PHP: ${PHP_VERSION}"
# Create storage directories if they don't exist
if [ ! -d /app/storage/app/public/ ]; then
mkdir -p /app/storage/app/public/;
fi
if [ ! -d /app/storage/app/public/patch-data/ ]; then
mkdir -p /app/storage/app/public/patch-data/;
fi
if [ ! -d /app/storage/framework/cache/data/ ]; then
mkdir -p /app/storage/framework/cache/data/;
fi
if [ ! -d /app/storage/framework/sessions/ ]; then
mkdir -p /app/storage/framework/sessions/;
fi
if [ ! -d /app/storage/framework/testing/ ]; then
mkdir -p /app/storage/framework/sessions/;
fi
if [ ! -d /app/storage/framework/views/ ]; then
mkdir -p /app/storage/framework/views/;
fi
if [ ! -d /app/storage/logs/ ]; then
mkdir -p /app/storage/logs/;
fi
# Set folder permissions
chown -R www-data:www-data /app/storage
# Link filesystem paths
/usr/local/bin/php artisan storage:link
# Run database migrations
/usr/local/bin/php artisan migrate --force --no-interaction
# Run Laravel Octane with FrankenPHP
/usr/local/bin/php artisan octane:frankenphp --port=80