- Dockerfile
- Install Nginx with the Openssl module to handle HTTPS connections. Source code & build instructions.
- Configuration
- Create and configure the
nginx.conf
- Create and configure the
- Dockerfile
- Install
mariadb-serverand create appropriate system user.
- Install
- Configuration
- Prepare a
mariadb.sourcefor the key to installingmariadb-serverfrom the official repository. - Comment out "bind-address" from the
50-server.cnf/my.cnf(default is localhost) in order to allow connections from any address.- these files are located just as references only; the actual configuration is applied directly in the Dockerfile.
- Prepare a
- Database installation:
- Reinitialize the system database with remote root access disabled and with anonymous users removed.
- Create WordPress database using
mariadb-client. - These steps are executed in the
docker-entrypoint.shafter the container creation.
- Dockerfile
- Install PHP with PHP-FPM, MySQL support.
- This image is used as a base image for PHP-FPM, WordPress and Adminer containers.
- Configuration
- Configure:
php-fpm.conf- Set
daemonize = no - Set
include=/usr/local/etc/php-fpm.d/\*.conf(The upstream default incorrectly sets this toinclude=NONE/etc/php-fpm.d/*.conf)
- Set
php.ini- Set
cgi.fix_pathinfo=0to prevent Nginx from passing requests to the PHP-FPM backend if the file does not exist, allowing us to prevent arbitrarily script injection.
- Set
www.conf- Set
clear_env = noto all environment variables available to PHP code; viagetenv(),$_ENVand$_SERVERthat are to be used inwp-config-docker.php
- Set
- Configure:
- Dockerfile
- Copy PHP_FPM binaries from the base image.
- Download WordPress source files and WP-CLI.
- Configuration
- Configure:
wp-config-docker.php
- Configure:
- Datatable installation
- Create WordPress database tables.
- Create an admin user in the database by WP-CLI.
- Install Redis Object Cache plugin by WP-CLI.
- Dockerfile
- Download and build source files for Redis.
- Configuration
- Configure:
redis.conf- Comment out
bind 127.0.0.1 -::1to listen on all interfaces. - Overwrite
protected-mode yestoprotected-mode noto allow connections from other containers. - Configure memory limits:
maxmemory 10mbmaxmemory-policy allkeys-lfu, all the keys will be evicted using an approximated LRU algorithm as long as we hit the 10 megabyte memory limit.- Redis cache configuration
- Comment out
- Configure:
- Dockerfile
- Copy PHP-FPM binaries from the base image.
- Download the
adminer.php.
- Dockerfile
- Build vsftpd from source following the
INSTALLfile.
- Build vsftpd from source following the
- Configuration
- vsftpd.conf
- Set
listen=YESto run vsftpd in standalone (no-daemonized) mode - Set
anonymous_enable=YESto allow access by an anonymous userftpto the server without password - Configure
pasv_min_port / pasv_max_portfor passive mode, a range of ports to be opened for data transfer.
- Set
- Ensure the firewall allows the port range properly.
- Port 21 (Control Port)
- This is the default, well-known port for FTP, used by the client to connect to the server and send commands like
USER,PASS,LIST,GET, orPUT. It manages the entire FTP session, but not the actual file data.
- This is the default, well-known port for FTP, used by the client to connect to the server and send commands like
- Port 20 (Data Port - Active Mode)
- In Active FTP, once a data transfer is requested, the server initiates a connection back to the client on its (client's) specified data port, often port 20 on the server side, to send the file.
- Dynamic Ports (Passive Mode)
- The server tells the client which port to use, and the client then connects to that specific port on the server for the data transfer.
- Port 21 (Control Port)
- Check the accessibility with
ftp ftp://localhost -P 21inside a container. seeftp --help
- vsftpd.conf
- Dockerfile
- Install
python3and dependencies such asFlask,gunicorn. - Run
gunicornwith the appropriate bind address.
- Install
- Application Structure
tools/
├── app.py
├── requirements.txt
│ ├── Flask
│ ├── python-dotenv
│ ├── watchdog
│ ├── greenlet
│ └── gunicorn
└── templates/
└── index.html
- Dockerfile
- Install Node.js for the runtime using NVM (node version manager).
- Install
pm2 - Clone the Uptime-kuma repository and run
server.js.
- Configuration
/etc/hosts- Sets the domain name as a host entry so it can be resolved.
- In this project, Docker compose manages this using the
extra_hostattribute.
- Domain name
- Configure the domain name
- Edit
/etc/hostsso the domain name points to the local IP (host) address.
- Edit
- Configure the domain name
- Firewall setup
- Ppen the ports:
- 443 for HTTPS connections.
- 20-21 and a dynamic port range(1024-1048 in this case) for the FTP server.
- Ppen the ports:
Using the Makefile:
make build
make upOr simply run:
makeUsing Docker Copmose:
docker build srcs/requirements/tools/php-fpm -t php-fpm-base:1.0.0
docker compose -f srcs/docker-compose.yml build
docker compose -f srcs/docker-compose.yml up -dNote: The PHP-FPM base image must be built first.
If you modified one of the Dockerfiles, you can rebuild only the corresponding image:
make build SERVICE="<service name>"List all containers, images, networks and volumes:
make lsStart containers
make upStop containers and remove them (but keep volumes):
make downor
make rmcRemove images:
make rmiRemove volumes:
make rmvRemove networks:
make rmnRemove unused system files:
make pruneRemove everything:
make cleanTo execute a command in a specific running container, run the following command and then specify a service name listed in docker-compose.yml and the command:
make execTo run a container and execute a command from an specific image, run the following command and then specify a service name listed in docker-compose.yml and the command:
make runEven if you remove Docker volumes, the data in the host’s binded paths persists. When new Docker volumes are created, these host paths are automatically re-bound to them.
If a container path that is mounted to a Docker volume contains data during the build process, and the volume is later bound to a host path, the data on the host overrides the existing container data.
To completely clean everything and start from scratch, you must also delete the host data. Use:
sudo make rm_hostdbYou can inspect the host paths that are binded to Docker volumes with:
make hostdbProject data is persisted using Docker volumes, which is stored within a directory on the Docker host and mounted into the container. A path on the host machine is mounted the volume so that you can see the data from the path.
- Host path:
/host/tmitsuya/data - Data for WordPress, MariaDB, Adminer, Uptime-kuma is stored in this path.