Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions .classpath

This file was deleted.

29 changes: 0 additions & 29 deletions .gitignore

This file was deleted.

34 changes: 0 additions & 34 deletions .project

This file was deleted.

4 changes: 0 additions & 4 deletions .settings/org.eclipse.core.resources.prefs

This file was deleted.

2 changes: 0 additions & 2 deletions .settings/org.eclipse.jdt.apt.core.prefs

This file was deleted.

9 changes: 0 additions & 9 deletions .settings/org.eclipse.jdt.core.prefs

This file was deleted.

4 changes: 0 additions & 4 deletions .settings/org.eclipse.m2e.core.prefs

This file was deleted.

7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM python:3.6
MAINTAINER Varun Manik "[email protected]"
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
ENTRYPOINT ["python"]
CMD ["app.py"]
119 changes: 37 additions & 82 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,109 +1,64 @@
# Jenkins-cicd
PG DO - CI/CD Pipeline with Jenkins Simplilearn

# AWS Ubuntu VM Provisioning steps
- Step 1: Click on Launch Instance
- Step 2 : Click on Software Image (AMI)
- Select Ubuntu
- Step 4: Key pair name – required
- Click on Create new key pair
- Put key pair name Jenkins-sl
- & Download it
- Step 5 : Click on Launch Instance
- Step 6 : Select your VM and Click connect
- Step 7 : You can see the terminal
- Step: Showing Github example

# Git Status
```
git --version
```
## cretae Dir
```
mkdir demo
cd demo
```
## GIT & Ubuntu SSH connection
```
ssh-keygen
# Installing Docker in Ubuntu

"Hit enter button 3 time"

cat ~/.ssh/id_rsa.pub
git clone [email protected]:manikcloud/Jenkins-cicd.git
history
history | cut -c 8-
```
sudo apt install docker.io -y
sudo systemctl start docker
sudo systemctl enable docker

# JENKINS INSTALLATION on UBUNTU 18.04, for Ubunt 22.04 please skip the step 3 & 4
```
sudo apt-get update
sudo apt install openjdk-8-jdk
sudo wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt install jenkins
sudo /etc/init.d/jenkins start
sudo service jenkins status
OR sudo cat /home/labsuser/jenkins/secrets/initialAdminPassword
history | cut -c 8-

# Installing Docker in Amazon linux
```
# Jenkins URL with port 8080
- http://x.x.x.x:8080/

replace x with your ip
sudo yum install docker -y
sudo systemctl start docker
sudo systemctl enable docker

# Change Security group rule for Jenkins
```
- Select your instance
- Down below select your security tab
- Click on the Security groups sg-0c51908b5fa4abf75 (launch-wizard-2)
- Click on the action
- Click on EDIT INBOUND RULE
- Select custom TCP and put port 8080
- Custom ip should be 0.0.0.0/0
- Click on Save the rule
```

# common error
# Simple Python Flask Dockerized Application#

- Git clone &
```
getting "E: Unable to locate package openjdk-8-jdk" message on java update
```

# Resolution
Run this command
git clone https://github.com/manikcloud/Jenkins-cicd.git

```
sudo apt update
- change the branch
```
git switch 8.2-python-flask-app
```
# Plugin Installation
dashboard>manage>jenkins>manage plugins>maven integration
## Build the image using the following command

```bash
sudo docker build -t flask-app:latest .
```

Run the Docker container using the command shown below.

# Jenkins Setting
```bash
sudo docker run -d -p 5000:5000 flask-app

```
Java_Home
/usr/lib/jvm/java-8-openjdk-amd64/
```

# Post Build Step
- The application will be accessible at http:127.0.0.1:5000
- If you are using AWS EC2 VM then first find ip address and the use the ip `http://<host_ip>:5000`

```
java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App

# Jenkins Job setup "execute shell"

```

# This project is parameterized
echo "running python-flask-app project"
#sudo docker rmi `docker images -aq` -f
sudo docker rm -f `docker ps -aq`
sudo docker build -t flask-app:$BUILD_ID .
sudo docker run -d -p 5000:5000 flask-app:$BUILD_ID

```
echo "User First name is : $First_Name"
echo "User Last name is : $Last_Name"
echo "User Gender is : $Sex"

## Common Error
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: connect: permission denied

- to overcome this error plz run the below command:
```
# References:
1. https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
2. https://maven.apache.org/download.cgi
chmod 777 /var/run/docker.sock
```
13 changes: 13 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from flask import Flask
import os

app = Flask(__name__)

@app.route("/")
def hello():
return "Flask inside Docker by Varun Manik 2023 Feb 19 Sunday!!"


if __name__ == "__main__":
port = int(os.environ.get("PORT", 5000))
app.run(debug=True,host='0.0.0.0',port=port)
Loading