diff --git a/docker-compose.yml b/docker-compose.yml index 88ab2ff29..af580e971 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,12 +1,14 @@ -version: '3.8' - services: php: - image: debian-php2 + build: + context: . + dockerfile: ./docker/php/Dockerfile + command: bash /var/www/html/docker/php/entrypoint.sh ports: - "80:80" volumes: - - ./docker/apache2/000-default.conf:/etc/apache2/sites-available/000-default.conf + - ./docker/php/apache.conf:/etc/apache2/sites-available/000-default.conf + - ./docker/php/logs:/var/log/apache2 - ./:/var/www/html - vendor:/var/www/html/vendor @@ -19,8 +21,8 @@ services: - MYSQL_PASSWORD=junghan5 volumes: - ./docker/mysql/data:/var/lib/mysql - - ./docker/mysql/conf.d:/etc/mysql/conf.d - - ./docker/mysql/logs:/var/log/mysql + - ./docker/mysql/conf.d:/etc/mysql/conf.d:ro + - ./docker/mysql/logs:/var/log/mysql:rw ports: - "3306:3306" @@ -29,7 +31,7 @@ services: ports: - "8080:8080" volumes: - - ./docker/adminer.php.ini:/etc/php/7.4/cli/conf.d/php.local.ini + - ./docker/adminer/php.ini:/etc/php/7.4/cli/conf.d/php.local.ini volumes: diff --git a/docker/SqlCollationSwitcher/SqlCollationSwitcher.ps1 b/docker/SqlCollationSwitcher/SqlCollationSwitcher.ps1 deleted file mode 100644 index e83ee8fe6..000000000 --- a/docker/SqlCollationSwitcher/SqlCollationSwitcher.ps1 +++ /dev/null @@ -1,34 +0,0 @@ -param( - [string]$compressedFile -) - -# Load .NET assembly for file handling -Add-Type -AssemblyName System.IO.Compression.FileSystem - -# Resolve absolute path of the compressed file -$absoluteCompressedFile = Resolve-Path $compressedFile - -# Generate file names -$workingDir = Split-Path $absoluteCompressedFile -$uncompressedFile = Join-Path $workingDir ($compressedFile -replace '^\.\\', '' -replace '\.sql\.gz$', '_uncompressed.sql') -$modifiedFile = Join-Path $workingDir ($compressedFile -replace '^\.\\', '' -replace '\.sql\.gz$', '_modified.sql') -$recompressedFile = Join-Path $workingDir ($compressedFile -replace '^\.\\', '' -replace '\.gz$', '_modified.sql.gz') - -# Decompress .sql.gz file using .NET Framework -[System.IO.Compression.ZipFile]::ExtractToDirectory($absoluteCompressedFile, $workingDir) - -# Read content of uncompressed file -$content = Get-Content -Path $uncompressedFile -Raw - -# Replace text -$content = $content -replace 'utf8mb4_0900_ai_ci', 'utf8mb4_general_ci' - -# Write modified content to file -Set-Content -Path $modifiedFile -Value $content -Encoding UTF8 - -# Compress .sql file back to .sql.gz using .NET Framework -[System.IO.Compression.ZipFile]::CreateFromDirectory($workingDir, $recompressedFile) - -# Cleanup: Optionally, you can remove the uncompressed and modified files if you don't need them anymore -# Remove-Item $uncompressedFile -# Remove-Item $modifiedFile diff --git a/docker/SqlCollationSwitcher/SqlCollationSwitcher2.ps1 b/docker/SqlCollationSwitcher/SqlCollationSwitcher2.ps1 deleted file mode 100644 index 8ee4b7362..000000000 --- a/docker/SqlCollationSwitcher/SqlCollationSwitcher2.ps1 +++ /dev/null @@ -1,21 +0,0 @@ -param( - [string]$compressedFile -) - -# Generate file names -$uncompressedFile = $compressedFile -replace '\.sql\.gz$', '_uncompressed.sql' -$modifiedFile = $compressedFile -replace '\.sql\.gz$', '_modified.sql' -$recompressedFile = $compressedFile -replace '\.gz$', '_modified.sql.gz' - -# Decompress .sql.gz file using 7-Zip -& "C:\Program Files\7-Zip\7z.exe" x -so $compressedFile | Set-Content -Path $uncompressedFile -Encoding UTF8 - -# Replace text using PowerShell -(Get-Content $uncompressedFile) -replace "utf8mb4_0900_ai_ci", "utf8mb4_general_ci" | Set-Content $modifiedFile -Encoding UTF8 - -# Compress .sql file back to .sql.gz using 7-Zip -& "C:\Program Files\7-Zip\7z.exe" a -tgzip $recompressedFile $modifiedFile - -# Cleanup: Optionally, you can remove the uncompressed and modified files if you don't need them anymore -#Remove-Item $uncompressedFile -#Remove-Item $modifiedFile diff --git a/docker/adminer.php.ini b/docker/adminer.php.ini deleted file mode 100644 index 41b09428e..000000000 --- a/docker/adminer.php.ini +++ /dev/null @@ -1,3 +0,0 @@ -post_max_size = 516M -upload_max_filesize = 516M -memory_limit = 2G diff --git a/docker/adminer/php.ini b/docker/adminer/php.ini new file mode 100644 index 000000000..81c83824e --- /dev/null +++ b/docker/adminer/php.ini @@ -0,0 +1,3 @@ +post_max_size = 2048M +upload_max_filesize = 2048M +memory_limit = 8G diff --git a/docker/mysql/apache2/000-default.conf b/docker/mysql/apache2/000-default.conf deleted file mode 100644 index 4eb0a724b..000000000 --- a/docker/mysql/apache2/000-default.conf +++ /dev/null @@ -1,31 +0,0 @@ - - # The ServerName directive sets the request scheme, hostname and port that - # the server uses to identify itself. This is used when creating - # redirection URLs. In the context of virtual hosts, the ServerName - # specifies what hostname must appear in the request's Host: header to - # match this virtual host. For the default virtual host (this file) this - # value is not decisive as it is used as a last resort host regardless. - # However, you must set it for any further virtual host explicitly. - #ServerName www.example.com - - ServerAdmin webmaster@localhost - DocumentRoot /var/www/html/public - - # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, - # error, crit, alert, emerg. - # It is also possible to configure the loglevel for particular - # modules, e.g. - #LogLevel info ssl:warn - - ErrorLog ${APACHE_LOG_DIR}/error.log - CustomLog ${APACHE_LOG_DIR}/access.log combined - - allowoverride all - - # For most configuration files from conf-available/, which are - # enabled or disabled at a global level, it is possible to - # include a line for only one particular virtual host. For example the - # following line enables the CGI configuration for this host only - # after it has been globally disabled with "a2disconf". - #Include conf-available/serve-cgi-bin.conf - diff --git a/Dockerfile b/docker/php/Dockerfile similarity index 53% rename from Dockerfile rename to docker/php/Dockerfile index cf1bf8fad..1583ab7b2 100644 --- a/Dockerfile +++ b/docker/php/Dockerfile @@ -3,32 +3,19 @@ FROM debian:bookworm # Install apache2 and PHP and PHP modules RUN apt update && \ - apt install -y apache2 php8.2 php8.2-mysqli php8.2-gd php8.2-zip php8.2-dom php8.2-mbstring && \ + apt install -y apache2 curl unzip php8.2 php8.2-curl php8.2-cli php8.2-mysqli php8.2-gd php8.2-zip php8.2-dom php8.2-mbstring && \ + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \ apt clean && \ rm -rf /var/lib/apt/lists/* # Enable PHP in Apache2 RUN a2enmod php8.2 - -# Enable Apache2 mod_rewrite RUN a2enmod rewrite -# Install Composer -RUN apt update && \ - apt install -y curl php8.2-cli unzip && \ - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \ - apt clean && \ - rm -rf /var/lib/apt/lists/* - -# Change PHP.ini memory limit to 1024MB -RUN sed -i 's/memory_limit = .*/memory_limit = 1024M/' /etc/php/8.2/apache2/php.ini - # Composer install WORKDIR /var/www/html -COPY composer.json composer.lock ./ +COPY ../../composer.json ./ RUN composer install --no-interaction - - # Start Apache in the foreground CMD ["apachectl", "-D", "FOREGROUND"] diff --git a/docker/apache2/000-default.conf b/docker/php/apache.conf similarity index 100% rename from docker/apache2/000-default.conf rename to docker/php/apache.conf diff --git a/docker/php/entrypoint.sh b/docker/php/entrypoint.sh new file mode 100644 index 000000000..8a7435fc8 --- /dev/null +++ b/docker/php/entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/bash +trap "echo 'Stopping Apache...'; apachectl stop; exit 0" SIGTERM +apachectl -D FOREGROUND & +# Wait for Apache and all child processes to exit +wait $!