Skip to content

Commit

Permalink
Merge pull request #15 from CyrilBaah/jenkins
Browse files Browse the repository at this point in the history
Jenkins setup
  • Loading branch information
ninadingole authored May 11, 2024
2 parents d6d0fb3 + f4f52a7 commit 7c58968
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ use `-d` to start compose in detach mode
| MySQL [Planned] | | |
| MongoDB [Planned] | | |
| CockroachDB [Planned] | | |
| [Jenkins](./jenkins/README.md) || |

## How to contribute

Expand Down
1 change: 1 addition & 0 deletions jenkins/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
JENKINS_AGENT_SSH_PUBLIC_KEY=
41 changes: 41 additions & 0 deletions jenkins/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Jenkins Setup

This repository contains a Docker Compose configuration for setting up Jenkins with an agent for building projects.

## Prerequisites

- Docker
- Docker Compose

## Services

### Jenkins Master

The Jenkins master service is based on the `jenkins/jenkins:lts` image and provides the Jenkins web interface.

- Access the Jenkins web interface at [http://localhost:8080](http://localhost:8080)
- Use the initial admin password to unlock Jenkins (found in the Jenkins logs or inside the container)

### Jenkins Agent

The Jenkins agent service is based on the `jenkins/ssh-agent:jdk11` image and provides the agent for building projects.

- Configure the agent in Jenkins using the SSH public key provided in the `JENKINS_AGENT_SSH_PUBLIC_KEY` environment variable.

## Usage

1. Create a .env file with the following content

```bash
JENKINS_AGENT_SSH_PUBLIC_KEY=YOUR_SSH_PUBLIC_KEY_HERE
```
Note: Replace YOUR_SSH_PUBLIC_KEY_HERE with your actual SSH public key. If you don't have an SSH key, you can generate one using the following command:
```bash
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
```
Follow the prompts to generate the SSH key. The public key will be saved to ~/.ssh/id_rsa.pub.

2. Start the Jenkins services:
```bash
docker-compose up -d
```
23 changes: 23 additions & 0 deletions jenkins/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: "3"
services:
jenkins:
image: jenkins/jenkins:lts
container_name: jenkins
privileged: true
user: root
ports:
- 8080:8080
- 50000:50000
volumes:
- /home/jenkins_home:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
agent:
image: jenkins/ssh-agent:jdk11
container_name: jenkins_agent1
privileged: true
user: root
expose:
- 22
environment:
- JENKINS_AGENT_SSH_PUBKEY=${JENKINS_AGENT_SSH_PUBLIC_KEY}

0 comments on commit 7c58968

Please # to comment.