Refactor Dockerfiles and scripts to streamline installation and configuration processes

This commit is contained in:
whaffman 2025-07-17 15:15:01 +02:00
parent a4c01aac2e
commit 8deb1c3223
6 changed files with 7 additions and 38 deletions

View File

@ -66,8 +66,6 @@ clean:
@echo "$(gub)Removing Docker images...$(reset)" @echo "$(gub)Removing Docker images...$(reset)"
@docker rmi -f $(shell docker images -q) @docker rmi -f $(shell docker images -q)
logs: logs:
@echo "$(gub)Displaying logs...$(reset)" @echo "$(gub)Displaying logs...$(reset)"
@$(DC) logs @$(DC) logs

View File

@ -2,7 +2,6 @@ FROM alpine:3.20
ARG HOST_UID=1000 ARG HOST_UID=1000
# Install PHP-FPM and dependencies for Adminer
RUN apk add --no-cache \ RUN apk add --no-cache \
php83 \ php83 \
php83-fpm \ php83-fpm \
@ -14,11 +13,9 @@ RUN apk add --no-cache \
curl && \ curl && \
rm -rf /var/cache/apk/* rm -rf /var/cache/apk/*
# Create user with matching UID
RUN addgroup -g ${HOST_UID} adminer && \ RUN addgroup -g ${HOST_UID} adminer && \
adduser -D -u ${HOST_UID} -G adminer adminer adduser -D -u ${HOST_UID} -G adminer adminer
# Create web directory and download Adminer
RUN mkdir -p /var/www/html && \ RUN mkdir -p /var/www/html && \
curl -L https://github.com/vrana/adminer/releases/download/v5.3.0/adminer-5.3.0.php -o /var/www/html/adminer.php && \ curl -L https://github.com/vrana/adminer/releases/download/v5.3.0/adminer-5.3.0.php -o /var/www/html/adminer.php && \
chown -R adminer:adminer /var/www/html chown -R adminer:adminer /var/www/html

View File

@ -1,6 +1,6 @@
FROM alpine:3.20 FROM alpine:3.20
# Accept build argument for host user ID
ARG HOST_UID=1000 ARG HOST_UID=1000
RUN apk add --no-cache \ RUN apk add --no-cache \

View File

@ -3,7 +3,6 @@
adduser -D -u "${HOST_UID}" -h /var/www/html -s /bin/false "${FTP_USER}" 2>/dev/null || true adduser -D -u "${HOST_UID}" -h /var/www/html -s /bin/false "${FTP_USER}" 2>/dev/null || true
echo "${FTP_USER}:${FTP_PASS}" | chpasswd echo "${FTP_USER}:${FTP_PASS}" | chpasswd
mkdir -p /var/www/html mkdir -p /var/www/html
# chown -R "${FTP_USER}:${FTP_USER}" /var/www/html
echo "${FTP_USER}" > /etc/vsftpd.userlist echo "${FTP_USER}" > /etc/vsftpd.userlist
exec vsftpd /etc/vsftpd/vsftpd.conf exec vsftpd /etc/vsftpd/vsftpd.conf

View File

@ -37,18 +37,12 @@ RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli
COPY ./conf/www.conf /etc/php83/php-fpm.d/www.conf COPY ./conf/www.conf /etc/php83/php-fpm.d/www.conf
RUN echo "memory_limit = 512M" >> /etc/php83/php.ini RUN echo "memory_limit = 512M" >> /etc/php83/php.ini && \
echo 'sendmail_path = "/usr/sbin/sendmail -S mailhog:1025"' >> /etc/php83/php.ini
# Copy and set permissions for the install script
COPY ./tools/install.sh /usr/local/bin/install.sh COPY ./tools/install.sh /usr/local/bin/install.sh
RUN chmod +x /usr/local/bin/install.sh RUN chmod +x /usr/local/bin/install.sh
# Switch to the new user
ENTRYPOINT ["/usr/local/bin/install.sh"] ENTRYPOINT ["/usr/local/bin/install.sh"]
CMD ["php-fpm83", "-F"] CMD ["php-fpm83", "-F"]

View File

@ -1,20 +1,12 @@
#!/bin/sh #!/bin/sh
# Set sendmail_path in php.ini for PHP 8.3 FPM
PHP_INI="/etc/php83/php.ini"
if [ -f "$PHP_INI" ]; then
sed -i '/^sendmail_path/d' "$PHP_INI"
echo 'sendmail_path = "/usr/sbin/sendmail -S mailhog:1025"' >> "$PHP_INI"
fi
# This script is used to install WordPress and configure it with a MariaDB database. if [ -f /var/www/html/wp-config.php ]; then
# It checks for the presence of a database and user, creates them if they don't exist, echo "WordPress is already installed."
# and sets up the WordPress configuration file with the database connection details. exec "$@"
fi
echo "Installing WordPress..." echo "Installing WordPress..."
sleep 10 sleep 10
# Check if the database exists
echo "wp core download --allow-root --path=/var/www/html" echo "wp core download --allow-root --path=/var/www/html"
wp core download --allow-root --path=/var/www/html wp core download --allow-root --path=/var/www/html
@ -68,17 +60,6 @@ wp config set --allow-root \
wp redis enable --allow-root \ wp redis enable --allow-root \
--path=/var/www/html --path=/var/www/html
# wp config set --allow-root \
# SMTP_SERVER \
# "mailhog" \
# --type=constant \
# --path=/var/www/html
# wp config set --allow-root \
# SMTP_PORT \
# 1025 \
# --type=constant \
# --path=/var/www/html
echo "WordPress installation completed." echo "WordPress installation completed."
chown -R wordpress:wordpress /var/www/html chown -R wordpress:wordpress /var/www/html