Deployment Overview of Jenkins on Server¶
Prerequisites and Basic Requirements¶
The deployment requires a server running the Ubuntu operating system. The installation process necessitates root privileges to manage system packages, repositories, and services. The following components are required: - Ubuntu OS with apt package manager. - Root access or sudo privileges. - Network connectivity to download the Jenkins repository and Java runtime. - Port 8080 must be accessible for the Jenkins application. - Ports 80 and 443 are required for the Nginx reverse proxy and SSL certificate management.
File and Directory Structure¶
The application and its supporting services utilize the following directory structure: - /usr/share/keyrings/jenkins-keyring.asc: Location of the Jenkins GPG key for repository verification. - /etc/apt/sources.list.d/jenkins.list: Configuration file for the Jenkins repository. - /root/nginx: Directory containing the Nginx and Certbot Docker Compose configuration. - /root/nginx/compose.yml: Docker Compose file defining the Nginx service. - /data/nginx/nginx-certbot.env: Environment file for Nginx configuration. - /data/nginx/user_conf.d: Directory containing custom Nginx configuration files. - /etc/letsencrypt: Volume mount point for SSL certificates managed by Certbot.
Application Installation Process¶
Jenkins is installed as a native system service using the official Debian repository. The installation includes the following steps: 1. The system package index is updated. 2. The Jenkins GPG key is downloaded from https://pkg.jenkins.io/debian-stable/jenkins.io-2026.key and saved to /usr/share/keyrings/jenkins-keyring.asc. 3. The Jenkins repository is added to the system with the URL https://pkg.jenkins.io/debian-stable binary/. 4. The jenkins package is installed via apt. 5. The Java Runtime Environment (OpenJDK 21) and fontconfig are installed as dependencies. 6. The Jenkins service is enabled to start on boot and is started immediately.
Docker Containers and Their Deployment¶
A reverse proxy and SSL management solution is deployed using Docker Compose. The configuration is located in /root/nginx/compose.yml. - The nginx service uses the image jonasal/nginx-certbot:latest. - The container is configured with restart: unless-stopped. - The service runs in host network mode. - The CERTBOT_EMAIL environment variable is set to [email protected]. - The container mounts the nginx_secrets volume to /etc/letsencrypt for certificate storage. - The container mounts /data/nginx/user_conf.d to /etc/nginx/user_conf.d for custom configurations. - Deployment is executed by running docker compose up -d within the /root/nginx directory.
Proxy Servers¶
Nginx acts as a reverse proxy for the Jenkins application, handling SSL termination via Certbot. - The proxy configuration is managed through the Docker container defined in the Compose file. - A custom configuration file located in /data/nginx/user_conf.d is modified to route traffic. - The proxy_pass directive is set to http://127.0.0.1:8080 within the location / block of the host configuration file. - SSL certificates are automatically managed by the nginx-certbot container using the Let's Encrypt service.
Starting, Stopping, and Updating¶
The Jenkins application is managed as a systemd service. - To start the service: systemctl start jenkins - To stop the service: systemctl stop jenkins - To enable the service on boot: systemctl enable jenkins - To check the service status: systemctl status jenkins
The Docker-based proxy stack is managed via Docker Compose commands executed from the /root/nginx directory: - To start or restart the proxy: docker compose up -d - To stop the proxy: docker compose down