diff --git a/Makefile b/Makefile index 52bea95..86c79c6 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: whaffman +#+ # # +#+ # # Created: 2025/05/12 15:33:56 by whaffman #+# #+# # -# Updated: 2025/05/22 10:25:47 by whaffman ######## odam.nl # +# Updated: 2025/05/22 16:23:30 by whaffman ######## odam.nl # # # # **************************************************************************** # @@ -15,13 +15,13 @@ DOCKER_COMPOSE = docker compose DOCKER_COMPOSE_FILE = ./srcs/docker-compose.yml DOCKER_ENV_FILE = ./srcs/.env -DATA_DIR = ./data +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) --env-file $(DOCKER_ENV_FILE) --project-name "" .PHONY: all build up down remove @@ -36,8 +36,8 @@ $(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)" $(DC) build --build-arg HOST_UID=$(UID) @@ -61,7 +61,7 @@ clean: @echo "$(gub)Removing Docker images...$(reset)" @docker rmi -f $(shell docker images -q) - + logs: @echo "$(gub)Displaying logs...$(reset)" diff --git a/srcs/docker-compose.yml b/srcs/docker-compose.yml index 7bc990f..44cd49c 100644 --- a/srcs/docker-compose.yml +++ b/srcs/docker-compose.yml @@ -81,6 +81,26 @@ services: - docker-network restart: unless-stopped + ftp: + container_name: ftp + image: ftp + build: + context: ./requirements/ftp + dockerfile: Dockerfile + depends_on: + - wordpress + environment: + - FTP_USER=${FTP_USER} + - FTP_PASS=${FTP_PASS} + - FTP_PORT=${FTP_PORT} + networks: + - docker-network + ports: + - '21:21' + - '30000-30009:30000-30009' + volumes: + - data_wordpress:/var/www/html + restart: unless-stopped networks: docker-network: @@ -93,12 +113,12 @@ volumes: driver: local driver_opts: type: none - device: ../data/mariadb + device: /home/whaffman/data/mariadb o: bind data_wordpress: name: data_wordpress driver: local driver_opts: type: none - device: ../data/wordpress + device: /home/whaffman/data/wordpress o: bind diff --git a/srcs/requirements/adminer/Dockerfile b/srcs/requirements/adminer/Dockerfile new file mode 100644 index 0000000..4b6d5f5 --- /dev/null +++ b/srcs/requirements/adminer/Dockerfile @@ -0,0 +1,16 @@ +FROM alpine:3.20 + +RUN apk add --no-cache \ + php83 \ + php83-fpm \ + php83-mysqli \ + php83-mbstring \ + php83-session \ + mariadb-client \ + curl &&\ + 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 +ARG HOST_UID + diff --git a/srcs/requirements/ftp/Dockerfile b/srcs/requirements/ftp/Dockerfile new file mode 100644 index 0000000..be4c1d7 --- /dev/null +++ b/srcs/requirements/ftp/Dockerfile @@ -0,0 +1,17 @@ +FROM alpine:3.20 + +RUN apk add --no-cache \ + vsftpd \ + && rm -rf /var/cache/apk/* + +RUN adduser -D -h /home/ftpuser -s /bin/false ftpuser && \ + echo "ftpuser:password" | chpasswd && \ + mkdir -p /home/ftpuser/ftp && \ + chmod 750 /home/ftpuser/ftp && \ + chown -R ftpuser:ftpuser /home/ftpuser/ftp + +COPY ./conf/vsftpd.conf /etc/vsftpd/vsftpd.conf + +EXPOSE 20 21 30000-30009 + +CMD ["vsftpd", "/etc/vsftpd/vsftpd.conf"] diff --git a/srcs/requirements/ftp/conf/vsftpd.conf b/srcs/requirements/ftp/conf/vsftpd.conf new file mode 100644 index 0000000..593e60e --- /dev/null +++ b/srcs/requirements/ftp/conf/vsftpd.conf @@ -0,0 +1,34 @@ +# Allow local users to log in +local_enable=YES + +# Enable write permissions for local users +write_enable=YES + +# Restrict users to their home directories +chroot_local_user=YES + +# Enable passive mode (useful for NAT and firewalls) +pasv_enable=YES +pasv_min_port=30000 +pasv_max_port=30009 + +# Disable anonymous login +anonymous_enable=NO + +# Set the FTP banner message +ftpd_banner=Welcome to the FTP server. + +# Listen on IPv4 +listen=YES + +# Disable IPv6 (optional, if not needed) +listen_ipv6=NO + +# Set the maximum number of clients +max_clients=10 + +# Set the maximum number of connections per IP +max_per_ip=5 + +# Log all FTP requests +xferlog_enable=YES \ No newline at end of file diff --git a/srcs/requirements/ftp/tools/docker-entrypoint.sh b/srcs/requirements/ftp/tools/docker-entrypoint.sh new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/srcs/requirements/ftp/tools/docker-entrypoint.sh @@ -0,0 +1 @@ + diff --git a/srcs/requirements/redis/Dockerfile b/srcs/requirements/redis/Dockerfile index 0a18c17..301c9d1 100644 --- a/srcs/requirements/redis/Dockerfile +++ b/srcs/requirements/redis/Dockerfile @@ -6,11 +6,6 @@ RUN apk add --no-cache \ redis && \ rm -rf /var/cache/apk/* -ARG HOST_UID - -# Expose the default Redis port -EXPOSE 6379 - # Set the working directory WORKDIR /data