Skip to content

Commit

Permalink
Merge pull request #32 from vectornguyen76/dev-cicd
Browse files Browse the repository at this point in the history
Dev cicd with jenkins
  • Loading branch information
vectornguyen76 committed Jan 4, 2024
2 parents 467baba + 756f0f8 commit 9546e80
Show file tree
Hide file tree
Showing 16 changed files with 190 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ image-search-engine/assets/uploaded_images/*
# Logs
# image-search-engine/logs/*

# Jenkins
*/run_env
jenkins/assets/*.mp4

# Model
*.pth
*.pt
Expand Down
21 changes: 21 additions & 0 deletions jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
pipeline {
agent any

stages {
stage('Build') {
steps {
echo 'Building something..'
}
}
stage('Test') {
steps {
echo 'Testing something..'
}
}
stage('Deploy') {
steps {
echo 'Deploying something..'
}
}
}
}
153 changes: 153 additions & 0 deletions jenkins/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# Official Jenkins Docker Image

[![Docker Stars](https://img.shields.io/docker/stars/jenkins/jenkins.svg)](https://hub.docker.com/r/jenkins/jenkins/)
[![Docker Pulls](https://img.shields.io/docker/pulls/jenkins/jenkins.svg)](https://hub.docker.com/r/jenkins/jenkins/)
[![Join the chat at https://gitter.im/jenkinsci/docker](https://badges.gitter.im/jenkinsci/docker.svg)](https://gitter.im/jenkinsci/docker?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

The Jenkins Continuous Integration and Delivery server [available on Docker Hub](https://hub.docker.com/r/jenkins/jenkins).

This is a fully functional Jenkins server. For more information, visit [https://jenkins.io/](https://jenkins.io/).

<img src="https://jenkins.io/sites/default/files/jenkins_logo.png"/>

## Table of Contents

- [Setup Jenkins](#setup-jenkins)
1. [Run Jenkins using Docker Compose](#1-run-jenkins-using-docker-compose)
2. [Access Jenkins and Login](#2-access-jenkins-and-login)
3. [Read Container Logs to Get Password](#3-read-container-logs-to-get-password)
4. [Install Suggested Plugins](#4-install-suggested-plugins)
5. [Skip User Registration and Continue as Admin](#5-skip-user-registration-and-continue-as-admin)
6. [Configure URL Instance](#6-configure-url-instance)
7. [Explore Jenkins UI](#7-explore-jenkins-ui)
- [Create CI/CD Pipeline](#create-cicd-pipeline)
1. [Get Access Token to Login to GitHub in Jenkins](#1-get-access-token-to-login-to-github-in-jenkins)
2. [Set Up Pipeline](#2-set-up-pipeline)
3. [Update Script Path](#3-update-script-path)
4. [Build CI/CD](#4-build-cicd)

## Setup Jenkins

### 1. Run Jenkins using Docker Compose

```bash
docker compose up -d
```

### 2. Access Jenkins and Login

Visit [http://localhost:8080](http://localhost:8080) and log in.

<p align="center">
<img src="./assets/login.png" alt="Login Jenkins" />
<br>
<em>Login Jenkins</em>
</p>

### 3. Read Container Logs to Get Password

```bash
docker logs jenkins
```

Alternatively,

```bash
docker exec -it jenkins cat /var/jenkins_home/secrets/initialAdminPassword
```

<p align="center">
<img src="./assets/check-password.png" alt="Get password in logs" />
<br>
<em>Get password in logs</em>
</p>

### 4. Install Suggested Plugins

Select "Install suggested plugins" and wait for Jenkins to install the required plugins.

<p align="center">
<img src="./assets/step1.png" alt="Install suggested plugins" />
<br>
<em>Install suggested plugins</em>
</p>

<p align="center">
<img src="./assets/step2.png" alt="Waiting for setup" />
<br>
<em>Waiting for setup</em>
</p>

### 5. Skip User Registration and Continue as Admin

Choose "Skip and continue as admin" when prompted during user registration.

<p align="center">
<img src="./assets/step3.png" alt="Skip and continue as admin" />
<br>
<em>Skip and continue as admin</em>
</p>

### 6. Configure URL Instance

Set up the URL for the Jenkins instance.

<p align="center">
<img src="./assets/step4.png" alt="Instance Configuration" />
<br>
<em>Instance Configuration</em>
</p>

### 7. Explore Jenkins UI

Explore the Jenkins UI at [http://localhost:8080](http://localhost:8080).

<p align="center">
<img src="./assets/jenkins-ui.png" alt="Jenkins UI" />
<br>
<em>Jenkins UI</em>
</p>

## Create CI/CD Pipeline

### 1. Get Access Token to Login to GitHub in Jenkins

Follow the GIF to obtain an access token in GitHub for Jenkins integration.

<p align="center">
<img src="./assets/get-token-github.gif" alt="Get access token in Github" />
<br>
<em>Get access token in Github</em>
</p>

_Remember to save the access token for the next step._

### 2. Set Up Pipeline

Add the saved access token in the password box when setting up the pipeline.

<p align="center">
<img src="./assets/setup-pipeline.gif" alt="Set up pipeline" />
<br>
<em>Set up pipeline</em>
</p>

### 3. Update Script Path

Update the script path as per your project configuration.

<p align="center">
<img src="./assets/script-path.png" alt="Script Path" />
<br>
<em>Script Path</em>
</p>

### 4. Build CI/CD

Initiate the CI/CD build process.

<p align="center">
<img src="./assets/build-cicd.png" alt="Build CI/CD" />
<br>
<em>Build CI/CD</em>
</p>
Binary file added jenkins/assets/build-cicd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jenkins/assets/check-password.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jenkins/assets/get-token-github.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jenkins/assets/jenkins-ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jenkins/assets/login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jenkins/assets/script-path.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jenkins/assets/setup-pipeline.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jenkins/assets/step1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jenkins/assets/step2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jenkins/assets/step3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jenkins/assets/step4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions jenkins/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: "3.7"
services:
jenkins:
image: jenkins/jenkins:lts-jdk17
privileged: true
user: root
ports:
- 8080:8080
- 50000:50000
container_name: jenkins
volumes:
- ./run_env/jenkins_home:/var/jenkins_home
Empty file added jenkins/run_env/.gitkeep
Empty file.

0 comments on commit 9546e80

Please sign in to comment.