lalal
This commit is contained in:
parent
4bf28f2e28
commit
0b15a19325
25
Makefile
25
Makefile
@ -6,20 +6,37 @@
|
|||||||
# By: whaffman <whaffman@student.codam.nl> +#+ #
|
# By: whaffman <whaffman@student.codam.nl> +#+ #
|
||||||
# +#+ #
|
# +#+ #
|
||||||
# Created: 2025/05/12 15:33:56 by whaffman #+# #+# #
|
# Created: 2025/05/12 15:33:56 by whaffman #+# #+# #
|
||||||
# Updated: 2025/05/19 13:22:28 by whaffman ######## odam.nl #
|
# Updated: 2025/05/20 22:14:24 by whaffman ######## odam.nl #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
|
||||||
DOCKER_COMPOSE = docker compose
|
DOCKER_COMPOSE = docker compose
|
||||||
DOCKER_COMPOSE_FILE = ./srcs/docker-compose.yml
|
DOCKER_COMPOSE_FILE = ./srcs/docker-compose.yml
|
||||||
DOCKER_ENV_FILE = ./srcs/.env
|
DOCKER_ENV_FILE = ./srcs/.env
|
||||||
|
|
||||||
DC = $(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) --env-file $(DOCKER_ENV_FILE)
|
DATA_DIR = ./data
|
||||||
|
WORDPRESS_DATA_DIR = $(DATA_DIR)/wordpress
|
||||||
|
MARIADB_DATA_DIR = $(DATA_DIR)/mariadb
|
||||||
|
|
||||||
|
DC = $(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) --env-file $(DOCKER_ENV_FILE) --project-name ""
|
||||||
|
|
||||||
.PHONY: all build up down remove
|
.PHONY: all build up down remove
|
||||||
|
|
||||||
all: build up
|
all: build up
|
||||||
build:
|
|
||||||
|
$(WORDPRESS_DATA_DIR):
|
||||||
|
@echo "$(gub)Creating WordPress data directory...$(reset)"
|
||||||
|
@mkdir -p $(WORDPRESS_DATA_DIR)
|
||||||
|
@chmod 777 $(WORDPRESS_DATA_DIR)
|
||||||
|
|
||||||
|
$(MARIADB_DATA_DIR):
|
||||||
|
@echo "$(gub)Creating MariaDB data directory...$(reset)"
|
||||||
|
@mkdir -p $(MARIADB_DATA_DIR)
|
||||||
|
@chmod 777 $(MARIADB_DATA_DIR)
|
||||||
|
|
||||||
|
|
||||||
|
build: $(WORDPRESS_DATA_DIR) $(MARIADB_DATA_DIR)
|
||||||
@echo "$(gub)Building Docker containers...$(reset)"
|
@echo "$(gub)Building Docker containers...$(reset)"
|
||||||
$(DC) build
|
$(DC) build
|
||||||
up:
|
up:
|
||||||
@ -54,7 +71,7 @@ ps:
|
|||||||
remove:
|
remove:
|
||||||
@echo "$(gub)Removing Docker containers...$(reset)"
|
@echo "$(gub)Removing Docker containers...$(reset)"
|
||||||
@$(DC) rm -f
|
@$(DC) rm -f
|
||||||
@$(DC) volume rm -f
|
@docker volume rm -f
|
||||||
@$(DC) network rm -f
|
@$(DC) network rm -f
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,11 @@ services:
|
|||||||
mariadb:
|
mariadb:
|
||||||
container_name: mariadb
|
container_name: mariadb
|
||||||
restart: always
|
restart: always
|
||||||
|
environment:
|
||||||
|
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
|
||||||
|
- MYSQL_DATABASE=${MYSQL_DATABASE}
|
||||||
|
- MYSQL_USER=${MYSQL_USER}
|
||||||
|
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
|
||||||
build:
|
build:
|
||||||
context: ./requirements/mariadb
|
context: ./requirements/mariadb
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
@ -27,27 +32,62 @@ services:
|
|||||||
# volumes:
|
# volumes:
|
||||||
# - data_wordpress:/var/www/html
|
# - data_wordpress:/var/www/html
|
||||||
|
|
||||||
# wordpress:
|
wordpress:
|
||||||
# restart: always
|
container_name: wordpress
|
||||||
# build:
|
restart: always
|
||||||
# context: ./requirements/wordpress
|
build:
|
||||||
# dockerfile: Dockerfile
|
context: ./requirements/wordpress
|
||||||
# depends_on:
|
dockerfile: Dockerfile
|
||||||
# - mariadb
|
depends_on:
|
||||||
# ports:
|
- mariadb
|
||||||
# - '9000:9000'
|
environment:
|
||||||
# networks:
|
- DOMAIN_NAME=whaffman.42.fr
|
||||||
# - docker-network
|
|
||||||
# volumes:
|
- MYSQL_DATABASE=wordpress
|
||||||
# - data_wordpress:/var/www/html
|
- MYSQL_USER=wordpress
|
||||||
|
- MYSQL_PASSWORD=42wordpress42
|
||||||
|
- MYSQL_ROOT_PASSWORD=42root42
|
||||||
|
|
||||||
|
- DB_HOST=mariadb
|
||||||
|
- DB_PORT=3306
|
||||||
|
|
||||||
|
- WP_TITLE=Inception
|
||||||
|
- WP_DESCRIPTION=Inception project
|
||||||
|
|
||||||
|
- WP_ADMIN=theboss
|
||||||
|
- WP_ADMIN_PASSWORD=42theboss42
|
||||||
|
- WP_ADMIN_EMAIL=inception@duinvoetje.nl
|
||||||
|
|
||||||
|
- WP_THEME=twentytwentyfour
|
||||||
|
|
||||||
|
- WP_USER=inception
|
||||||
|
- WP_USER_PASSWORD=42inception42
|
||||||
|
- WP_USER_EMAIL=inception@duinvoetje.nl
|
||||||
|
ports:
|
||||||
|
- '9000:9000'
|
||||||
|
networks:
|
||||||
|
- docker-network
|
||||||
|
volumes:
|
||||||
|
- data_wordpress:/var/www/html
|
||||||
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
docker-network:
|
docker-network:
|
||||||
|
name: docker-network
|
||||||
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
data_mariadb:
|
data_mariadb:
|
||||||
|
name: data_mariadb
|
||||||
driver: local
|
driver: local
|
||||||
|
driver_opts:
|
||||||
|
type: none
|
||||||
|
device: ../data/mariadb
|
||||||
|
o: bind
|
||||||
data_wordpress:
|
data_wordpress:
|
||||||
|
name: data_wordpress
|
||||||
driver: local
|
driver: local
|
||||||
|
driver_opts:
|
||||||
|
type: none
|
||||||
|
device: ../data/wordpress
|
||||||
|
o: bind
|
||||||
|
|||||||
@ -2,5 +2,4 @@
|
|||||||
port=3306
|
port=3306
|
||||||
bind-address=0.0.0.0
|
bind-address=0.0.0.0
|
||||||
datadir=/var/lib/mysql
|
datadir=/var/lib/mysql
|
||||||
socket=/var/run/mysqld/mysql.sock
|
|
||||||
pid-file=/var/run/mysqld/mysqld.pid
|
pid-file=/var/run/mysqld/mysqld.pid
|
||||||
|
|||||||
@ -6,7 +6,7 @@ if [ "$1" = 'mysqld' ]; then
|
|||||||
# Initialize the database if it doesn't exist
|
# Initialize the database if it doesn't exist
|
||||||
if [ ! -d "/var/lib/mysql/mysql" ]; then
|
if [ ! -d "/var/lib/mysql/mysql" ]; then
|
||||||
echo "Initializing database..."
|
echo "Initializing database..."
|
||||||
mysql_install_db --user=mysql --datadir=/var/lib/mysql --rpm
|
mysql_install_db --user=mariadb --datadir=/var/lib/mysql --rpm
|
||||||
echo "Database initialized."
|
echo "Database initialized."
|
||||||
|
|
||||||
# Start MariaDB temporarily to set up initial configuration
|
# Start MariaDB temporarily to set up initial configuration
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
FROM alpine:3.20
|
FROM alpine:3.20
|
||||||
|
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
nginx \
|
nginx &&\
|
||||||
rm -rf /var/cache/apk/*
|
rm -rf /var/cache/apk/*
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@ RUN apk add --no-cache \
|
|||||||
php83-gd \
|
php83-gd \
|
||||||
php83-session \
|
php83-session \
|
||||||
mariadb-client \
|
mariadb-client \
|
||||||
curl \
|
curl &&\
|
||||||
rm -rf /var/cache/apk/*
|
rm -rf /var/cache/apk/*
|
||||||
|
|
||||||
# Add a new user and group
|
# Add a new user and group
|
||||||
@ -34,9 +34,11 @@ RUN echo "memory_limit = 512M" >> /etc/php83/php.ini
|
|||||||
# Copy and set permissions for the install script
|
# 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
|
||||||
RUN /usr/local/bin/install.sh
|
|
||||||
|
|
||||||
# Switch to the new user
|
# Switch to the new user
|
||||||
USER wordpress
|
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/local/bin/install.sh"]
|
||||||
|
|
||||||
CMD ["php-fpm83", "-F"]
|
CMD ["php-fpm83", "-F"]
|
||||||
@ -1,9 +1,12 @@
|
|||||||
#!bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# This script is used to install WordPress and configure it with a MariaDB database.
|
# This script is used to install WordPress and configure it with a MariaDB database.
|
||||||
# It checks for the presence of a database and user, creates them if they don't exist,
|
# It checks for the presence of a database and user, creates them if they don't exist,
|
||||||
# and sets up the WordPress configuration file with the database connection details.
|
# and sets up the WordPress configuration file with the database connection details.
|
||||||
|
echo "Installing WordPress..."
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
# Check if the database exists
|
||||||
wp core download --allow-root --path=/var/www/html
|
wp core download --allow-root --path=/var/www/html
|
||||||
wp config create --allow-root \
|
wp config create --allow-root \
|
||||||
--dbname=$MYSQL_DATABASE \
|
--dbname=$MYSQL_DATABASE \
|
||||||
@ -29,3 +32,6 @@ wp theme install --allow-root \
|
|||||||
--activate \
|
--activate \
|
||||||
--path=/var/www/html
|
--path=/var/www/html
|
||||||
|
|
||||||
|
echo "WordPress installation completed."
|
||||||
|
|
||||||
|
exec "$@"
|
||||||
Loading…
Reference in New Issue
Block a user