Deployment Overview of Drupal on Server¶
Prerequisites and Basic Requirements¶
The deployment requires a Linux server running Ubuntu with root privileges. The following components must be present or installed: - Docker Engine installed and running. - Docker Compose installed for managing multi-container applications. - A custom Docker network named {{ prefix }}-net created to isolate application traffic. - Port 8080 available on the host to access the Drupal web interface. - Port 3306 used internally for MariaDB communication within the Docker network.
File and Directory Structure¶
The configuration and data files are organized in the following locations on the host server: - /root/nginx/: Contains the Docker Compose configuration for the proxy and SSL management. - /root/nginx/compose.yml: The Docker Compose file defining the Nginx and Certbot services. - /data/nginx/nginx-certbot.env: Environment file containing configuration variables for the Nginx proxy. - /data/nginx/user_conf.d/: Directory storing custom Nginx configuration files for specific domains. - /etc/letsencrypt/: Mount point for SSL certificates managed by Certbot.
Application Installation Process¶
The application is deployed using Docker containers. The installation involves starting two primary containers: a database container and the Drupal application container.
- Database Container:
- Image:
{{ db_image }}(MariaDB). - Container Name:
{{ db_container_name }}. - Configuration: The container is initialized with the root password, database name, user, and password via environment variables.
- Network: Connected to the
{{ prefix }}-netnetwork. -
Restart Policy: Set to
always. -
Drupal Container:
- Image:
{{ drupal_image }}. - Container Name:
{{ drupal_container_name }}. - Port Mapping: Host port
8080maps to container port80. - Database Connection: Configured via environment variables pointing to the database container.
- Network: Connected to the
{{ prefix }}-netnetwork. - Restart Policy: Set to
always.
Docker Containers and Their Deployment¶
The system utilizes Docker to run the application stack. The containers are managed individually via the Docker CLI or through the Docker Compose file for the proxy.
- MariaDB Container:
- Launched with the command equivalent to
docker runusing the{{ db_image }}image. -
Environment variables
MYSQL_ROOT_PASSWORD,MYSQL_DATABASE,MYSQL_USER, andMYSQL_PASSWORDare passed to configure the database instance. -
Drupal Container:
- Launched with the command equivalent to
docker runusing the{{ drupal_image }}image. -
Environment variables
DRUPAL_DB_HOST,DRUPAL_DB_NAME,DRUPAL_DB_USER,DRUPAL_DB_PASSWORD, andDRUPAL_DB_PORTare set to establish the connection to the MariaDB container. -
Nginx and Certbot Container:
- Managed via
docker compose up -din the/root/nginxdirectory. - Uses the
jonasal/nginx-certbot:latestimage. - Runs in
hostnetwork mode. - Mounts the
nginx_secretsvolume to/etc/letsencryptfor certificate storage. - Mounts
/data/nginx/user_conf.dto/etc/nginx/user_conf.dfor custom configurations.
Proxy Servers¶
The deployment includes an Nginx proxy server integrated with Certbot for SSL certificate management.
- Service Image:
jonasal/nginx-certbot:latest. - Email Configuration: Certbot is configured to use
[email protected]for notifications. - Environment File: Loads settings from
/data/nginx/nginx-certbot.env. - Volume Mounts:
nginx_secrets(external volume) mounted at/etc/letsencrypt.- Host directory
/data/nginx/user_conf.dmounted at/etc/nginx/user_conf.d. - Network Mode: The proxy container operates in
hostnetwork mode to handle incoming traffic directly. - Restart Policy: Set to
unless-stopped.
Databases¶
The application uses a MariaDB database hosted within a Docker container.
- Connection Method: The Drupal container connects to the database using the internal Docker network hostname
{{ db_container_name }}. - Port: The database listens on port
3306within the Docker network. - Configuration:
- Database Name:
{{ db_name }}. - Database User:
{{ db_user }}. - Database Password:
{{ db_password }}. - Root Password:
{{ db_root_password }}. - Storage: Database data is stored within the container's writable layer or attached volumes defined by the Docker runtime.
Starting, Stopping, and Updating¶
The services are managed using Docker commands.
- Starting the Proxy:
- Navigate to the
/root/nginxdirectory. -
Execute
docker compose up -dto start the Nginx and Certbot services in detached mode. -
Starting the Application Containers:
- The MariaDB and Drupal containers are started with the
docker_containermodule, which ensures they are running with the specified configuration. -
To manually start a stopped container, use
docker start <container_name>. -
Stopping the Application Containers:
-
To stop a container, use
docker stop <container_name>. -
Updating the Application:
- To update the application, pull the latest images using
docker pull {{ drupal_image }}anddocker pull {{ db_image }}. - Recreate the containers using
docker-compose up -dfor the proxy ordocker runcommands with the updated images for the application and database.
Access Rights and Security¶
- Directory Permissions:
- The
/root/nginxdirectory is owned byrootwith permissions0755. - The
compose.ymlfile is owned byrootwith permissions0644. - Network Isolation:
- All application containers communicate over the isolated
{{ prefix }}-netDocker network. - SSL Certificates:
- Certificates are stored in the
nginx_secretsvolume, which is mounted to/etc/letsencryptinside the proxy container.