reworked docker setup
This commit is contained in:
@@ -1,12 +1,14 @@
|
|||||||
version: '3.8'
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
php:
|
php:
|
||||||
image: debian-php2
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: ./docker/php/Dockerfile
|
||||||
|
command: bash /var/www/html/docker/php/entrypoint.sh
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
volumes:
|
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
|
- ./:/var/www/html
|
||||||
- vendor:/var/www/html/vendor
|
- vendor:/var/www/html/vendor
|
||||||
|
|
||||||
@@ -19,8 +21,8 @@ services:
|
|||||||
- MYSQL_PASSWORD=junghan5
|
- MYSQL_PASSWORD=junghan5
|
||||||
volumes:
|
volumes:
|
||||||
- ./docker/mysql/data:/var/lib/mysql
|
- ./docker/mysql/data:/var/lib/mysql
|
||||||
- ./docker/mysql/conf.d:/etc/mysql/conf.d
|
- ./docker/mysql/conf.d:/etc/mysql/conf.d:ro
|
||||||
- ./docker/mysql/logs:/var/log/mysql
|
- ./docker/mysql/logs:/var/log/mysql:rw
|
||||||
ports:
|
ports:
|
||||||
- "3306:3306"
|
- "3306:3306"
|
||||||
|
|
||||||
@@ -29,7 +31,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- "8080:8080"
|
||||||
volumes:
|
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:
|
volumes:
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
post_max_size = 516M
|
|
||||||
upload_max_filesize = 516M
|
|
||||||
memory_limit = 2G
|
|
||||||
3
docker/adminer/php.ini
Normal file
3
docker/adminer/php.ini
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
post_max_size = 2048M
|
||||||
|
upload_max_filesize = 2048M
|
||||||
|
memory_limit = 8G
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
<VirtualHost *:80>
|
|
||||||
# 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
|
|
||||||
<Directory /var/www/html>
|
|
||||||
allowoverride all
|
|
||||||
</Directory>
|
|
||||||
# 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
|
|
||||||
</VirtualHost>
|
|
||||||
@@ -3,32 +3,19 @@ FROM debian:bookworm
|
|||||||
|
|
||||||
# Install apache2 and PHP and PHP modules
|
# Install apache2 and PHP and PHP modules
|
||||||
RUN apt update && \
|
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 && \
|
apt clean && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Enable PHP in Apache2
|
# Enable PHP in Apache2
|
||||||
RUN a2enmod php8.2
|
RUN a2enmod php8.2
|
||||||
|
|
||||||
# Enable Apache2 mod_rewrite
|
|
||||||
RUN a2enmod 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
|
# Composer install
|
||||||
WORKDIR /var/www/html
|
WORKDIR /var/www/html
|
||||||
COPY composer.json composer.lock ./
|
COPY ../../composer.json ./
|
||||||
RUN composer install --no-interaction
|
RUN composer install --no-interaction
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Start Apache in the foreground
|
# Start Apache in the foreground
|
||||||
CMD ["apachectl", "-D", "FOREGROUND"]
|
CMD ["apachectl", "-D", "FOREGROUND"]
|
||||||
5
docker/php/entrypoint.sh
Normal file
5
docker/php/entrypoint.sh
Normal file
@@ -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 $!
|
||||||
Reference in New Issue
Block a user