Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07506ed53a |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +0,0 @@
|
||||
data/
|
||||
54
Makefile
54
Makefile
@ -6,49 +6,23 @@
|
||||
# By: whaffman <whaffman@student.codam.nl> +#+ #
|
||||
# +#+ #
|
||||
# Created: 2025/05/12 15:33:56 by whaffman #+# #+# #
|
||||
# Updated: 2025/05/22 16:23:30 by whaffman ######## odam.nl #
|
||||
# Updated: 2025/05/13 08:59:04 by whaffman ######## odam.nl #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
|
||||
DOCKER_COMPOSE = docker compose
|
||||
DOCKER_COMPOSE_FILE = ./srcs/docker-compose.yml
|
||||
DOCKER_ENV_FILE = ./srcs/.env
|
||||
|
||||
DATA_DIR = /home/whaffman/data
|
||||
WORDPRESS_DATA_DIR = $(DATA_DIR)/wordpress
|
||||
MARIADB_DATA_DIR = $(DATA_DIR)/mariadb
|
||||
|
||||
UID := $(shell id -u)
|
||||
|
||||
DC = $(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) --env-file $(DOCKER_ENV_FILE) --project-name ""
|
||||
DC = $(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE)
|
||||
|
||||
.PHONY: all build up down remove
|
||||
|
||||
all: build up
|
||||
|
||||
$(DATA_DIR):
|
||||
@echo "$(gub)Creating data directory...$(reset)"
|
||||
@mkdir -p $(DATA_DIR)
|
||||
@chmod 777 $(DATA_DIR)
|
||||
|
||||
$(WORDPRESS_DATA_DIR): $(DATA_DIR)
|
||||
@echo "$(gub)Creating WordPress data directory...$(reset)"
|
||||
@mkdir -p $(WORDPRESS_DATA_DIR)
|
||||
@chmod 777 $(WORDPRESS_DATA_DIR)
|
||||
|
||||
$(MARIADB_DATA_DIR): $(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)
|
||||
build:
|
||||
@echo "$(gub)Building Docker containers...$(reset)"
|
||||
$(DC) build --build-arg HOST_UID=$(UID)
|
||||
up: $(WORDPRESS_DATA_DIR) $(MARIADB_DATA_DIR)
|
||||
$(DC) build
|
||||
up:
|
||||
@echo "$(gub)Starting Docker containers...$(reset)"
|
||||
$(DC) up -d
|
||||
$(DC) up -d --build
|
||||
|
||||
down:
|
||||
@echo "$(gub)Stopping Docker containers...$(reset)"
|
||||
@ -57,14 +31,6 @@ down:
|
||||
clean:
|
||||
@echo "$(gub)Cleaning up Docker containers...$(reset)"
|
||||
$(DC) down --rmi local --volumes --remove-orphans
|
||||
@echo "$(gub)Removing data directories...$(reset)"
|
||||
@rm -rf $(DATA_DIR)
|
||||
@echo "$(gub)Removing Docker networks...$(reset)"
|
||||
@docker network prune -f
|
||||
@echo "$(gub)Removing Docker volumes...$(reset)"
|
||||
@docker volume prune -f
|
||||
@echo "$(gub)Removing Docker images...$(reset)"
|
||||
@docker rmi -f $(shell docker images -q)
|
||||
|
||||
logs:
|
||||
@echo "$(gub)Displaying logs...$(reset)"
|
||||
@ -82,6 +48,14 @@ ps:
|
||||
@echo "$(gub)Displaying all containers...$(reset)"
|
||||
@docker ps -a
|
||||
|
||||
|
||||
remove:
|
||||
@echo "$(gub)Removing Docker containers...$(reset)"
|
||||
@$(DC) rm -f
|
||||
@$(DC) volume rm -f
|
||||
@$(DC) network rm -f
|
||||
|
||||
|
||||
# Colors
|
||||
|
||||
green:=$(shell tput setaf 2)
|
||||
|
||||
0
secrets/credentials.txt
Normal file
0
secrets/credentials.txt
Normal file
1
secrets/db_password.txt
Normal file
1
secrets/db_password.txt
Normal file
@ -0,0 +1 @@
|
||||
test
|
||||
1
secrets/db_root_password.txt
Normal file
1
secrets/db_root_password.txt
Normal file
@ -0,0 +1 @@
|
||||
test
|
||||
22
setup.sh
22
setup.sh
@ -1,22 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
SUBDOMAINS=(
|
||||
"whaffman.42.fr" "mail.whaffman.42.fr" "adminer.whaffman.42.fr" "ftp.whaffman.42.fr" "static.whaffman.42.fr")
|
||||
HOSTS_FILE="/etc/hosts"
|
||||
IP="127.0.0.1"
|
||||
|
||||
for SUBDOMAIN in "${SUBDOMAINS[@]}"; do
|
||||
if ! grep -q "$SUBDOMAIN" "$HOSTS_FILE"; then
|
||||
echo "$IP $SUBDOMAIN" | sudo tee -a "$HOSTS_FILE" > /dev/null
|
||||
echo "Added $SUBDOMAIN to $HOSTS_FILE"
|
||||
else
|
||||
echo "$SUBDOMAIN already exists in $HOSTS_FILE"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "/home/whaffman" ]; then
|
||||
sudo mkdir -p /home/whaffman
|
||||
echo "Created /home/whaffman"
|
||||
fi
|
||||
sudo chmod 777 /home/whaffman
|
||||
echo "Granted read/write permissions to everyone for /home/whaffman"
|
||||
31
srcs/.env
31
srcs/.env
@ -1,31 +0,0 @@
|
||||
DOMAIN_NAME=whaffman.42.fr
|
||||
|
||||
MYSQL_DATABASE=wordpress
|
||||
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=my-minimalist-blog
|
||||
|
||||
WP_USER=inception
|
||||
WP_USER_PASSWORD=42inception42
|
||||
WP_USER_EMAIL=inception2@duinvoetje.nl
|
||||
|
||||
FTP_USER=ftpuser
|
||||
FTP_PASS=42ftp42
|
||||
FTP_PORT=21
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,173 +1,72 @@
|
||||
name: inception
|
||||
|
||||
services:
|
||||
mariadb:
|
||||
container_name: mariadb
|
||||
restart: always
|
||||
build:
|
||||
context: ./requirements/mariadb
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
HOST_UID: ${HOST_UID:-1000}
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
|
||||
- MYSQL_DATABASE=${MYSQL_DATABASE}
|
||||
- MYSQL_USER=${MYSQL_USER}
|
||||
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
|
||||
- HOST_UID=${HOST_UID:-1000}
|
||||
ports:
|
||||
- '3306:3306'
|
||||
networks:
|
||||
- docker-network
|
||||
volumes:
|
||||
- data_mariadb:/var/lib/mysql
|
||||
restart: unless-stopped
|
||||
secrets:
|
||||
- mariadb_root_password
|
||||
- mariadb_user_password
|
||||
env_file:
|
||||
- ./requirements/mariadb/.env
|
||||
|
||||
nginx:
|
||||
container_name: nginx
|
||||
build:
|
||||
context: ./requirements/nginx
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
DOMAIN_NAME: ${DOMAIN_NAME}
|
||||
depends_on:
|
||||
wordpress:
|
||||
condition: service_healthy
|
||||
mailhog:
|
||||
condition: service_healthy
|
||||
adminer:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
- DOMAIN_NAME=${DOMAIN_NAME}
|
||||
ports:
|
||||
- '443:443'
|
||||
networks:
|
||||
- docker-network
|
||||
volumes:
|
||||
- data_wordpress:/var/www/html
|
||||
restart: unless-stopped
|
||||
|
||||
wordpress:
|
||||
container_name: wordpress
|
||||
build:
|
||||
context: ./requirements/wordpress
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
HOST_UID: ${HOST_UID:-1000}
|
||||
depends_on:
|
||||
mariadb:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
mailhog:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
- DOMAIN_NAME=${DOMAIN_NAME}
|
||||
|
||||
- DB_HOST=${DB_HOST}
|
||||
- DB_PORT=${DB_PORT}
|
||||
# wordpress:
|
||||
# container_name: wordpress
|
||||
# restart: always
|
||||
# build:
|
||||
# context: ./requirements/wordpress
|
||||
# dockerfile: Dockerfile
|
||||
# depends_on:
|
||||
# - mariadb
|
||||
# ports:
|
||||
# - '9000:9000'
|
||||
# networks:
|
||||
# - docker-network
|
||||
# volumes:
|
||||
# - data_wordpress:/var/www/html
|
||||
|
||||
- MYSQL_DATABASE=${MYSQL_DATABASE}
|
||||
- MYSQL_USER=${MYSQL_USER}
|
||||
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
|
||||
|
||||
- WP_TITLE=${WP_TITLE}
|
||||
- WP_DESCRIPTION=${WP_DESCRIPTION}
|
||||
- WP_THEME=${WP_THEME}
|
||||
|
||||
- WP_ADMIN=${WP_ADMIN}
|
||||
- WP_ADMIN_PASSWORD=${WP_ADMIN_PASSWORD}
|
||||
- WP_ADMIN_EMAIL=${WP_ADMIN_EMAIL}
|
||||
|
||||
- WP_USER=${WP_USER}
|
||||
- WP_USER_PASSWORD=${WP_USER_PASSWORD}
|
||||
- WP_USER_EMAIL=${WP_USER_EMAIL}
|
||||
networks:
|
||||
- docker-network
|
||||
volumes:
|
||||
- data_wordpress:/var/www/html
|
||||
restart: unless-stopped
|
||||
|
||||
redis:
|
||||
container_name: redis
|
||||
build:
|
||||
context: ./requirements/redis
|
||||
dockerfile: Dockerfile
|
||||
networks:
|
||||
- docker-network
|
||||
restart: unless-stopped
|
||||
|
||||
ftp:
|
||||
container_name: ftp
|
||||
build:
|
||||
context: ./requirements/ftp
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
HOST_UID: ${HOST_UID:-1000}
|
||||
depends_on:
|
||||
wordpress:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
- FTP_USER=${FTP_USER}
|
||||
- FTP_PASS=${FTP_PASS}
|
||||
- FTP_PORT=${FTP_PORT}
|
||||
- HOST_UID=${HOST_UID:-1000}
|
||||
networks:
|
||||
- docker-network
|
||||
ports:
|
||||
- '21:21'
|
||||
- '30000-30009:30000-30009'
|
||||
volumes:
|
||||
- data_wordpress:/var/www/html
|
||||
restart: unless-stopped
|
||||
stop_grace_period: 2s
|
||||
adminer:
|
||||
container_name: adminer
|
||||
build:
|
||||
context: ./requirements/adminer
|
||||
dockerfile: Dockerfile
|
||||
depends_on:
|
||||
mariadb:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
- ADMINER_DEFAULT_SERVER=mariadb
|
||||
networks:
|
||||
- docker-network
|
||||
restart: unless-stopped
|
||||
|
||||
mailhog:
|
||||
container_name: mailhog
|
||||
build:
|
||||
context: ./requirements/mailhog
|
||||
dockerfile: Dockerfile
|
||||
networks:
|
||||
- docker-network
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- HOST_UID=${HOST_UID:-1000}=value
|
||||
|
||||
static-site:
|
||||
container_name: static-site
|
||||
build:
|
||||
context: ./requirements/static-site
|
||||
dockerfile: Dockerfile
|
||||
environment:
|
||||
- DOMAIN_NAME=${DOMAIN_NAME}
|
||||
networks:
|
||||
- docker-network
|
||||
restart: unless-stopped
|
||||
# nginx:
|
||||
# container_name: nginx
|
||||
# restart: always
|
||||
# build:
|
||||
# context: ./requirements/nginx
|
||||
# dockerfile: Dockerfile
|
||||
# depends_on:
|
||||
# - wordpress
|
||||
# ports:
|
||||
# - '443:443'
|
||||
# networks:
|
||||
# - docker-network
|
||||
# volumes:
|
||||
# - data_wordpress:/var/www/html
|
||||
|
||||
networks:
|
||||
docker-network:
|
||||
name: docker-network
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
data_mariadb:
|
||||
name: data_mariadb
|
||||
driver: local
|
||||
driver_opts:
|
||||
type: none
|
||||
device: /home/whaffman/data/mariadb
|
||||
o: bind
|
||||
data_wordpress:
|
||||
name: data_wordpress
|
||||
driver: local
|
||||
driver_opts:
|
||||
type: none
|
||||
device: /home/whaffman/data/wordpress
|
||||
o: bind
|
||||
# data_wordpress:
|
||||
# driver: local
|
||||
|
||||
secrets:
|
||||
mariadb_root_password:
|
||||
file: ../secrets/db_root_password.txt
|
||||
mariadb_user_password:
|
||||
file: ../secrets/db_password.txt
|
||||
# wordpress_admin_password:
|
||||
# file: ./requirements/wordpress/.env
|
||||
# wordpress_user_password:
|
||||
# file: ./requirements/wordpress/.env
|
||||
@ -1,29 +0,0 @@
|
||||
FROM alpine:3.20
|
||||
|
||||
ARG HOST_UID=1000
|
||||
|
||||
RUN apk add --no-cache \
|
||||
php83 \
|
||||
php83-fpm \
|
||||
php83-mysqli \
|
||||
php83-mbstring \
|
||||
php83-session \
|
||||
php83-json \
|
||||
mariadb-client \
|
||||
netcat-openbsd \
|
||||
curl && \
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
RUN addgroup -g ${HOST_UID} adminer && \
|
||||
adduser -D -u ${HOST_UID} -G adminer adminer
|
||||
|
||||
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 && \
|
||||
chown -R adminer:adminer /var/www/html
|
||||
|
||||
COPY ./conf/www.conf /etc/php83/php-fpm.d/www.conf
|
||||
|
||||
CMD ["php-fpm83", "-F"]
|
||||
HEALTHCHECK --interval=10s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD nc -z 127.0.0.1 9000 || exit 1
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
[www]
|
||||
listen = 0.0.0.0:9000
|
||||
user = adminer
|
||||
group = adminer
|
||||
pm = dynamic
|
||||
pm.max_children = 5
|
||||
pm.start_servers = 2
|
||||
pm.min_spare_servers = 1
|
||||
pm.max_spare_servers = 3
|
||||
catch_workers_output = yes
|
||||
@ -1,19 +0,0 @@
|
||||
FROM alpine:3.20
|
||||
|
||||
|
||||
ARG HOST_UID=1000
|
||||
|
||||
RUN apk add --no-cache \
|
||||
vsftpd \
|
||||
netcat-openbsd \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
COPY ./conf/vsftpd.conf /etc/vsftpd/vsftpd.conf
|
||||
COPY ./tools/docker-entrypoint.sh /docker-entrypoint.sh
|
||||
RUN chmod +x /docker-entrypoint.sh
|
||||
|
||||
EXPOSE 20 21 30000-30009
|
||||
|
||||
CMD ["/docker-entrypoint.sh"]
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
||||
CMD nc -z localhost 21 || exit 1
|
||||
@ -1,22 +0,0 @@
|
||||
# Access settings
|
||||
local_enable=YES
|
||||
anonymous_enable=NO
|
||||
|
||||
# Write settings
|
||||
write_enable=YES
|
||||
allow_writeable_chroot=YES
|
||||
|
||||
# Chroot settings
|
||||
chroot_local_user=YES
|
||||
|
||||
# Listen settings
|
||||
listen=YES
|
||||
background=NO
|
||||
|
||||
# Security settings
|
||||
seccomp_sandbox=NO
|
||||
|
||||
# Passive mode settings
|
||||
pasv_enable=YES
|
||||
pasv_min_port=30000
|
||||
pasv_max_port=30009
|
||||
@ -1,8 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
adduser -D -u "${HOST_UID}" -h /var/www/html -s /bin/false "${FTP_USER}" 2>/dev/null || true
|
||||
echo "${FTP_USER}:${FTP_PASS}" | chpasswd
|
||||
mkdir -p /var/www/html
|
||||
echo "${FTP_USER}" > /etc/vsftpd.userlist
|
||||
|
||||
exec vsftpd /etc/vsftpd/vsftpd.conf
|
||||
@ -1,28 +0,0 @@
|
||||
FROM alpine:3.21 AS builder
|
||||
|
||||
RUN apk add --no-cache \
|
||||
go \
|
||||
git \
|
||||
netcat-openbsd \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
ENV GOROOT /usr/lib/go
|
||||
ENV GOPATH /go
|
||||
ENV PATH /go/bin:$PATH
|
||||
|
||||
RUN mkdir -p ${GOPATH}/src ${GOPATH}/bin
|
||||
|
||||
RUN go install github.com/mailhog/MailHog@latest
|
||||
|
||||
FROM alpine:3.20
|
||||
|
||||
ARG HOST_UID=1000
|
||||
|
||||
RUN adduser -D -u ${HOST_UID} mailhog
|
||||
|
||||
COPY --from=builder /go/bin/MailHog /usr/local/bin/MailHog
|
||||
|
||||
CMD ["MailHog"]
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
||||
CMD nc -z localhost 8025 || exit 1
|
||||
4
srcs/requirements/mariadb/.env
Normal file
4
srcs/requirements/mariadb/.env
Normal file
@ -0,0 +1,4 @@
|
||||
MYSQL_ROOT_PASSWORD=123456
|
||||
MYSQL_DATABASE=wordpress
|
||||
MYSQL_USER=wordpress
|
||||
MYSQL_PASSWORD=123456
|
||||
@ -1,31 +1,44 @@
|
||||
|
||||
FROM alpine:3.20
|
||||
|
||||
RUN apk add --no-cache \
|
||||
RUN apk update && apk upgrade && \
|
||||
apk add --no-cache \
|
||||
mariadb \
|
||||
mariadb-client && \
|
||||
mariadb-client \
|
||||
mariadb-server-utils && \
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
ARG HOST_UID
|
||||
|
||||
RUN addgroup -S -g $HOST_UID mariadb && \
|
||||
adduser -S -u $HOST_UID mariadb -G mariadb
|
||||
|
||||
# Create a new user and group
|
||||
RUN addgroup -S mariadb && adduser -S mariadb -G mariadb
|
||||
# Create the data directory
|
||||
RUN mkdir -p /var/lib/mysql && \
|
||||
chown -R mariadb:mariadb /var/lib/mysql && \
|
||||
chmod 700 /var/lib/mysql
|
||||
# Create the socket directory
|
||||
RUN mkdir -p /var/run/mysqld && \
|
||||
chown -R mariadb:mariadb /var/run/mysqld && \
|
||||
chown -R mariadb:mariadb /var/lib/mysql && \
|
||||
chmod -R 750 /var/lib/mysql
|
||||
|
||||
COPY ./tools/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
||||
COPY ./conf/my.cnf /etc/my.cnf
|
||||
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
||||
|
||||
chmod 755 /var/run/mysqld
|
||||
# Create the configuration directory
|
||||
# Set the working directory
|
||||
WORKDIR /var/lib/mysql
|
||||
# Expose the MySQL port
|
||||
EXPOSE 3306
|
||||
# Set the default environment variables
|
||||
|
||||
# Copy the configuration file
|
||||
COPY ./conf/my.cnf /etc/my.cnf
|
||||
# Make the configuration file readable by the user
|
||||
RUN chown mariadb:mariadb /etc/my.cnf
|
||||
|
||||
|
||||
# Copy the entrypoint script
|
||||
COPY ./tools/entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
# Make the entrypoint script executable
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||
# Set the default user to run the container
|
||||
USER mariadb
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
||||
|
||||
CMD ["mysqld", "--datadir=/var/lib/mysql", "--user=mariadb"]
|
||||
HEALTHCHECK --interval=5s --timeout=3s --start-period=5s --retries=1 CMD mysqladmin ping -h localhost || exit 1
|
||||
# # Set the entrypoint script
|
||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||
# Set the default command to run when the container starts
|
||||
CMD ["mysqld", "--bind-address=0.0.0.0"]
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
[mysqld]
|
||||
port = 3306
|
||||
bind-address=0.0.0.0
|
||||
datadir = /var/lib/mysql
|
||||
pid-file=/var/run/mysqld/mysqld.pid
|
||||
socket = /var/run/mysqld/mysqld.sock
|
||||
skip-networking = false
|
||||
bind-address = 0.0.0.0
|
||||
@ -1,19 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
if [ "$1" = 'mysqld' ] && [ ! -d "/var/lib/mysql/mysql" ]; then
|
||||
mysql_install_db --user=mariadb --datadir=/var/lib/mysql --rpm
|
||||
mysqld --user=mariadb --skip-networking &
|
||||
pid=$!
|
||||
while ! mysqladmin ping --silent; do sleep 1; done
|
||||
mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}';"
|
||||
[ "$MYSQL_DATABASE" ] && mysql -e "CREATE DATABASE IF NOT EXISTS \`${MYSQL_DATABASE}\`;"
|
||||
[ "$MYSQL_USER" ] && [ "$MYSQL_PASSWORD" ] && \
|
||||
mysql -e "CREATE USER '${MYSQL_USER}'@'%' IDENTIFIED BY '${MYSQL_PASSWORD}';" && \
|
||||
mysql -e "GRANT ALL PRIVILEGES ON \`${MYSQL_DATABASE}\`.* TO '${MYSQL_USER}'@'%';"
|
||||
mysql -e "FLUSH PRIVILEGES;"
|
||||
# [ -f "/usr/bin/local/init.sql" ] && mysql "${MYSQL_DATABASE}" < /usr/bin/local/init.sql
|
||||
kill "$pid" && wait "$pid"
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
32
srcs/requirements/mariadb/tools/entrypoint.sh
Normal file
32
srcs/requirements/mariadb/tools/entrypoint.sh
Normal file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
echo "Hello from mariadb entrypoint.sh"
|
||||
echo db: $MYSQL_DATABASE
|
||||
|
||||
mysql_install_db
|
||||
if [ -d "/var/lib/mysql/$MYSQL_DATABASE" ]
|
||||
then
|
||||
|
||||
echo "Database already exists"
|
||||
else
|
||||
|
||||
# Set root option so that connexion without root password is not possible
|
||||
|
||||
|
||||
|
||||
|
||||
#Add a root user on 127.0.0.1 to allow remote connexion
|
||||
#Flush privileges allow to your sql tables to be updated automatically when you modify it
|
||||
#mysql -uroot launch mysql command line client
|
||||
echo "GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY '$MYSQL_ROOT_PASSWORD'; FLUSH PRIVILEGES;" | mysql -uroot
|
||||
|
||||
#Create database and user in the database for wordpress
|
||||
|
||||
echo "CREATE DATABASE IF NOT EXISTS $MYSQL_DATABASE; GRANT ALL ON $MYSQL_DATABASE.* TO '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD'; FLUSH PRIVILEGES;" | mysql -u root
|
||||
|
||||
#Import database in the mysql command line
|
||||
# mysql -uroot -p$MYSQL_ROOT_PASSWORD $MYSQL_DATABASE < /usr/local/bin/wordpress.sql
|
||||
|
||||
fi
|
||||
|
||||
|
||||
exec "$@"
|
||||
@ -1,21 +1,6 @@
|
||||
FROM alpine:3.20
|
||||
|
||||
RUN apk add --no-cache \
|
||||
RUN apk update && apk upgrade && \
|
||||
apk add --no-cache \
|
||||
nginx \
|
||||
openssl \
|
||||
curl &&\
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
ARG DOMAIN_NAME
|
||||
|
||||
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
|
||||
-keyout /etc/ssl/private/nginx-selfsigned.key \
|
||||
-out /etc/ssl/certs/nginx-selfsigned.crt \
|
||||
-subj "/CN=*.${DOMAIN_NAME}"
|
||||
|
||||
COPY ./conf/nginx.conf /etc/nginx/nginx.conf
|
||||
RUN sed -i "s/\${DOMAIN_NAME}/${DOMAIN_NAME}/g" /etc/nginx/nginx.conf
|
||||
EXPOSE 443 8443
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
HEALTHCHECK --interval=5s --timeout=3s --start-period=5s --retries=1 \
|
||||
CMD curl --insecure -f https://127.0.0.1:443/ || exit 1
|
||||
|
||||
@ -1,88 +0,0 @@
|
||||
user nginx;
|
||||
worker_processes 1;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name mail.${DOMAIN_NAME};
|
||||
|
||||
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
|
||||
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
|
||||
location / {
|
||||
proxy_pass http://mailhog:8025;
|
||||
chunked_transfer_encoding on;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-NginX-Proxy true;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_http_version 1.1;
|
||||
proxy_redirect off;
|
||||
proxy_buffering off;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name adminer.${DOMAIN_NAME};
|
||||
|
||||
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
|
||||
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
|
||||
|
||||
location / {
|
||||
fastcgi_pass adminer:9000;
|
||||
fastcgi_param SCRIPT_FILENAME /var/www/html/adminer.php;
|
||||
include fastcgi_params;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name static.${DOMAIN_NAME};
|
||||
|
||||
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
|
||||
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
|
||||
location / {
|
||||
proxy_pass http://static-site:80;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name ${DOMAIN_NAME};
|
||||
|
||||
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
|
||||
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
|
||||
root /var/www/html;
|
||||
|
||||
index index.html index.htm index.php;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php$is_args$args;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass wordpress:9000;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi.conf;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,21 +0,0 @@
|
||||
FROM alpine:3.20
|
||||
|
||||
# Install Redis and its dependencies
|
||||
|
||||
RUN apk add --no-cache \
|
||||
redis && \
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /data
|
||||
|
||||
# Set Redis to run as a non-root user (optional)
|
||||
|
||||
RUN chown -R redis:redis /data
|
||||
|
||||
USER redis
|
||||
|
||||
# Start Redis server
|
||||
CMD ["redis-server", "--protected-mode", "no"]
|
||||
HEALTHCHECK --interval=10s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD redis-cli ping || exit 1
|
||||
@ -1,10 +0,0 @@
|
||||
FROM alpine:3.20
|
||||
|
||||
RUN apk add --no-cache lighttpd && \
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
# Copy your static site files into the web root
|
||||
COPY site/ /var/www/localhost/htdocs/
|
||||
|
||||
# Run Lighttpd in the foreground
|
||||
CMD ["lighttpd", "-D", "-f", "/etc/lighttpd/lighttpd.conf"]
|
||||
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generator: Adobe Illustrator 18.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Calque_1" sodipodi:docname="42_logo.svg" inkscape:version="0.48.2 r9819" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 -200 960 960" enable-background="new 0 -200 960 960" xml:space="preserve">
|
||||
<polygon id="polygon5" points="32,412.6 362.1,412.6 362.1,578 526.8,578 526.8,279.1 197.3,279.1 526.8,-51.1 362.1,-51.1 32,279.1 "/>
|
||||
<polygon id="polygon7" points="597.9,114.2 762.7,-51.1 597.9,-51.1 "/>
|
||||
<polygon id="polygon9" points="762.7,114.2 597.9,279.1 597.9,443.9 762.7,443.9 762.7,279.1 928,114.2 928,-51.1 762.7,-51.1 "/>
|
||||
<polygon id="polygon11" points="928,279.1 762.7,443.9 928,443.9 "/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.1 KiB |
@ -1,64 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Welcome to WHAFFMAN</title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background-color: #f4f4f4;
|
||||
color: #333;
|
||||
text-align: center;
|
||||
padding: 50px;
|
||||
}
|
||||
h1 {
|
||||
color: #2c3e50;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.icon {
|
||||
font-size: 100px;
|
||||
color: #3498db;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.services-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
max-width: 400px;
|
||||
margin: 30px auto 0 auto;
|
||||
text-align: left;
|
||||
}
|
||||
.services-list li {
|
||||
background: #fff;
|
||||
margin-bottom: 15px;
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 6px rgba(0,0,0,0.07);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
.services-list li i {
|
||||
margin-right: 15px;
|
||||
color: #3498db;
|
||||
font-size: 1.5em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<img src="./42_logo.svg" alt="42 Logo" style="height: 100px; margin-bottom: 20px;">
|
||||
<h1>Welcome to whaffman.42.fr</h1>
|
||||
<h2>Available Services</h2>
|
||||
<ul class="services-list">
|
||||
<li><i class="fas fa-database"></i> MariaDB</li>
|
||||
<li><i class="fas fa-server"></i> Nginx</li>
|
||||
<li><i class="fas fa-blog"></i> WordPress</li>
|
||||
<li><i class="fas fa-cog"></i> Adminer</li>
|
||||
<li><i class="fas fa-memory"></i> Redis</li>
|
||||
<li><i class="fas fa-envelope"></i> Mailhog</li>
|
||||
<li><i class="fas fa-globe"></i> Static Website</li>
|
||||
<li><i class="fas fa-file-upload"></i> FTP</li>
|
||||
<!-- Add or edit services as needed -->
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,50 +1,3 @@
|
||||
FROM alpine:3.20
|
||||
|
||||
ARG HOST_UID
|
||||
|
||||
# Install WordPress and its dependencies
|
||||
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 \
|
||||
php83-tokenizer \
|
||||
mariadb-client \
|
||||
curl \
|
||||
busybox-extras &&\
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
# Add a new user and group
|
||||
# Create group with GID = HOST_UID, then user with UID = HOST_UID and GID = HOST_UID
|
||||
RUN addgroup -g ${HOST_UID} wordpress && \
|
||||
adduser -D -u ${HOST_UID} -G wordpress wordpress
|
||||
|
||||
# Set ownership of the working directory
|
||||
RUN mkdir -p /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 ./conf/www.conf /etc/php83/php-fpm.d/www.conf
|
||||
|
||||
RUN echo "memory_limit = 512M" >> /etc/php83/php.ini && \
|
||||
echo 'sendmail_path = "/usr/sbin/sendmail -S mailhog:1025"' >> /etc/php83/php.ini
|
||||
|
||||
COPY ./tools/install.sh /usr/local/bin/install.sh
|
||||
RUN chmod +x /usr/local/bin/install.sh
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/install.sh"]
|
||||
|
||||
CMD ["php-fpm83", "-F"]
|
||||
HEALTHCHECK --interval=10s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD nc -z 127.0.0.1 9000 || exit 1
|
||||
RUN apk update && apk upgrade
|
||||
@ -1,10 +0,0 @@
|
||||
[www]
|
||||
listen = 0.0.0.0:9000
|
||||
user = wordpress
|
||||
group = wordpress
|
||||
pm = dynamic
|
||||
pm.max_children = 5
|
||||
pm.start_servers = 2
|
||||
pm.min_spare_servers = 1
|
||||
pm.max_spare_servers = 3
|
||||
catch_workers_output = yes
|
||||
@ -1,67 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
if [ -f /var/www/html/wp-config.php ]; then
|
||||
echo "WordPress is already installed."
|
||||
exec "$@"
|
||||
fi
|
||||
echo "Installing WordPress..."
|
||||
|
||||
echo "wp core download --allow-root --path=/var/www/html"
|
||||
wp core download --allow-root --path=/var/www/html
|
||||
|
||||
echo "wp config create --allow-root"
|
||||
wp config create --allow-root \
|
||||
--dbname=$MYSQL_DATABASE \
|
||||
--dbuser=$MYSQL_USER \
|
||||
--dbpass=$MYSQL_PASSWORD \
|
||||
--dbhost=$DB_HOST \
|
||||
--path=/var/www/html
|
||||
|
||||
echo "wp core install --allow-root"
|
||||
wp core install --allow-root \
|
||||
--url=$DOMAIN_NAME \
|
||||
--title=$WP_TITLE \
|
||||
--admin_user=$WP_ADMIN \
|
||||
--admin_password=$WP_ADMIN_PASSWORD \
|
||||
--admin_email=$WP_ADMIN_EMAIL \
|
||||
--path=/var/www/html
|
||||
|
||||
echo "wp user create --allow-root"
|
||||
wp user create --allow-root \
|
||||
$WP_USER \
|
||||
$WP_USER_EMAIL \
|
||||
--role=author \
|
||||
--user_pass=$WP_USER_PASSWORD \
|
||||
--path=/var/www/html
|
||||
|
||||
echo "wp theme install --allow-root"
|
||||
wp theme install --allow-root \
|
||||
$WP_THEME \
|
||||
--activate \
|
||||
--path=/var/www/html
|
||||
|
||||
wp plugin install --allow-root \
|
||||
redis-cache \
|
||||
--activate \
|
||||
--path=/var/www/html
|
||||
wp config set --allow-root \
|
||||
WP_REDIS_HOST \
|
||||
"redis" \
|
||||
--type=constant \
|
||||
--path=/var/www/html
|
||||
|
||||
wp config set --allow-root \
|
||||
WP_REDIS_PORT \
|
||||
6379 \
|
||||
--type=constant \
|
||||
--path=/var/www/html
|
||||
|
||||
wp redis enable --allow-root \
|
||||
--path=/var/www/html
|
||||
|
||||
echo "WordPress installation completed."
|
||||
|
||||
chown -R wordpress:wordpress /var/www/html
|
||||
|
||||
exec "$@"
|
||||
Loading…
Reference in New Issue
Block a user