From 4bf28f2e2857781df0160eeebff248bffb7c4013 Mon Sep 17 00:00:00 2001 From: whaffman Date: Tue, 20 May 2025 11:55:54 -0400 Subject: [PATCH] worktree clean --- srcs/.env | 2 +- srcs/docker-compose.yml | 27 ++++----- srcs/requirements/mariadb/Dockerfile | 6 +- .../mariadb/tools/docker-entrypoint.sh | 2 +- srcs/requirements/wordpress/Dockerfile | 55 +++++++++++-------- 5 files changed, 52 insertions(+), 40 deletions(-) diff --git a/srcs/.env b/srcs/.env index d9758d8..fad03ad 100644 --- a/srcs/.env +++ b/srcs/.env @@ -5,7 +5,7 @@ MYSQL_USER=wordpress MYSQL_PASSWORD=42wordpress42 MYSQL_ROOT_PASSWORD=42root42 -DB_HOST=localhost +DB_HOST=mariadb DB_PORT=3306 WP_TITLE=Inception diff --git a/srcs/docker-compose.yml b/srcs/docker-compose.yml index 4633461..9d6b43b 100644 --- a/srcs/docker-compose.yml +++ b/srcs/docker-compose.yml @@ -2,6 +2,7 @@ version: '3.8' services: mariadb: + container_name: mariadb restart: always build: context: ./requirements/mariadb @@ -26,19 +27,19 @@ services: # volumes: # - data_wordpress:/var/www/html - wordpress: - restart: always - build: - context: ./requirements/wordpress - dockerfile: Dockerfile - depends_on: - - mariadb - ports: - - '9000:9000' - networks: - - docker-network - volumes: - - data_wordpress:/var/www/html + # wordpress: + # restart: always + # build: + # context: ./requirements/wordpress + # dockerfile: Dockerfile + # depends_on: + # - mariadb + # ports: + # - '9000:9000' + # networks: + # - docker-network + # volumes: + # - data_wordpress:/var/www/html networks: diff --git a/srcs/requirements/mariadb/Dockerfile b/srcs/requirements/mariadb/Dockerfile index 46e724c..d7f4796 100644 --- a/srcs/requirements/mariadb/Dockerfile +++ b/srcs/requirements/mariadb/Dockerfile @@ -28,22 +28,22 @@ RUN mkdir -p /var/run/mysqld && \ COPY ./tools/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh COPY ./conf/my.cnf /etc/my.cnf # COPY ./init.sql /usr/local/bin/init.sql -RUN chmod +x /usr/local/bin/docker-entrypoint.sh # Expose the MySQL port EXPOSE 3306 # Set the user and group to run the container -USER mariadb:mariadb +RUN chmod +x /usr/local/bin/docker-entrypoint.sh # Set the working directory WORKDIR /var/lib/mysql # Set the entrypoint script to be executed when the container starts # The entrypoint script will initialize the database and start the server +USER mariadb ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] # Start the MariaDB server -CMD ["mysqld"] +CMD ["mysqld", "--datadir=/var/lib/mysql", "--user=mariadb"] diff --git a/srcs/requirements/mariadb/tools/docker-entrypoint.sh b/srcs/requirements/mariadb/tools/docker-entrypoint.sh index b250636..889c2a1 100644 --- a/srcs/requirements/mariadb/tools/docker-entrypoint.sh +++ b/srcs/requirements/mariadb/tools/docker-entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e # If the first argument is 'mysqld', then start MariaDB diff --git a/srcs/requirements/wordpress/Dockerfile b/srcs/requirements/wordpress/Dockerfile index 99ac3fa..f4befe3 100644 --- a/srcs/requirements/wordpress/Dockerfile +++ b/srcs/requirements/wordpress/Dockerfile @@ -1,31 +1,42 @@ -FROM:alpine:3.20 +FROM alpine:3.20 # Install WordPress and its dependencies -# The --no-cache option is used to prevent the package manager from caching the downloaded packages -# rm -rf /var/cache/apk/* is used to remove any cached files after installation -# This helps to keep the image size small RUN apk add --no-cache \ + php83 \ + php83-phar \ php83-fpm \ - php83-mysqli \ - php83-mbstring \ - php83-json \ - php83-curl \ - php83-xml \ - php83-zip \ - php83-gd \ - php83-session \ - mariadb-client \ - rm -rf /var/cache/apk/* + php83-mysqli \ + php83-mbstring \ + php83-json \ + php83-curl \ + php83-xml \ + php83-zip \ + php83-gd \ + php83-session \ + mariadb-client \ + curl \ + rm -rf /var/cache/apk/* -RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \ - chmod +x wp-cli.phar && \ - mv wp-cli.phar /usr/local/bin/wp +# Add a new user and group +RUN adduser -D -g 'wordpress' wordpress +# Set ownership of the working directory RUN mkdir -p /var/www/html && \ - chown -R www-data:www-data /var/www/html + chown -R wordpress:wordpress /var/www/html +# Install WP-CLI +RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \ + chmod +x wp-cli.phar && \ + mv wp-cli.phar /usr/local/bin/wp -# Copy the entrypoint script and configuration files -# and set the necessary permissions -# The entrypoint script will be responsible for initializing the database -COPY ./docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh +RUN echo "memory_limit = 512M" >> /etc/php83/php.ini + +# Copy and set permissions for the install script +COPY ./tools/install.sh /usr/local/bin/install.sh +RUN chmod +x /usr/local/bin/install.sh +RUN /usr/local/bin/install.sh + +# Switch to the new user +USER wordpress + +CMD ["php-fpm83", "-F"] \ No newline at end of file