Skip to content

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 }}-net network.
  • Restart Policy: Set to always.

  • Drupal Container:

  • Image: {{ drupal_image }}.
  • Container Name: {{ drupal_container_name }}.
  • Port Mapping: Host port 8080 maps to container port 80.
  • Database Connection: Configured via environment variables pointing to the database container.
  • Network: Connected to the {{ prefix }}-net network.
  • 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 run using the {{ db_image }} image.
  • Environment variables MYSQL_ROOT_PASSWORD, MYSQL_DATABASE, MYSQL_USER, and MYSQL_PASSWORD are passed to configure the database instance.

  • Drupal Container:

  • Launched with the command equivalent to docker run using the {{ drupal_image }} image.
  • Environment variables DRUPAL_DB_HOST, DRUPAL_DB_NAME, DRUPAL_DB_USER, DRUPAL_DB_PASSWORD, and DRUPAL_DB_PORT are set to establish the connection to the MariaDB container.

  • Nginx and Certbot Container:

  • Managed via docker compose up -d in the /root/nginx directory.
  • Uses the jonasal/nginx-certbot:latest image.
  • Runs in host network mode.
  • Mounts the nginx_secrets volume to /etc/letsencrypt for certificate storage.
  • Mounts /data/nginx/user_conf.d to /etc/nginx/user_conf.d for 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.d mounted at /etc/nginx/user_conf.d.
  • Network Mode: The proxy container operates in host network 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 3306 within 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/nginx directory.
  • Execute docker compose up -d to start the Nginx and Certbot services in detached mode.

  • Starting the Application Containers:

  • The MariaDB and Drupal containers are started with the docker_container module, 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 }} and docker pull {{ db_image }}.
  • Recreate the containers using docker-compose up -d for the proxy or docker run commands with the updated images for the application and database.

Access Rights and Security

  • Directory Permissions:
  • The /root/nginx directory is owned by root with permissions 0755.
  • The compose.yml file is owned by root with permissions 0644.
  • Network Isolation:
  • All application containers communicate over the isolated {{ prefix }}-net Docker network.
  • SSL Certificates:
  • Certificates are stored in the nginx_secrets volume, which is mounted to /etc/letsencrypt inside the proxy container.
question_mark
Is there anything I can help you with?
question_mark
AI Assistant ×