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
7 changes: 7 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MYSQL_IP=mysqlserverhost
MYSQL_USER=
MYSQL_PASS=
MYSQL_DBNAME=toolingdb

env.BRANCH_NAME=feature
env.BUILD_NUMBER='0.0.1'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM php:7-apache
MAINTAINER Dare dare@darey.io
# MAINTAINER Dare dare@darey.io

ENV MYSQL_IP=$MYSQL_IP
ENV MYSQL_USER=$MYSQL_USER
Expand Down
96 changes: 38 additions & 58 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,73 +1,53 @@
pipeline {
agent {
kubernetes {
yaml '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: maven
image: maven:alpine
command:
- cat
tty: true
- name: docker
image: docker:latest
command:
- cat
tty: true
volumeMounts:
- mountPath: /var/run/docker.sock
name: docker-sock
volumes:
- name: docker-sock
hostPath:
path: /var/run/docker.sock
'''
}
agent any
options {
buildDiscarder(logRotator(numToKeepStr: '5'))
}
environment {
DOCKERHUB_CREDENTIALS = credentials('dockerhub')
}

stages {
stage('Clone') {
steps {
container('maven') {
git branch: 'main', changelog: false, poll: false, url: 'https://mohdsabir-cloudside@bitbucket.org/mohdsabir-cloudside/java-app.git'
}
}
}
stage('Build-Jar-file') {
stage('Build image for tooling-app') {
steps {
container('maven') {
sh 'mvn package'
}
sh 'docker build -t stlng/tooling-${env.BRANCH_NAME}:${env.BUILD_NUMBER} .'
}
}
stage('Build-Docker-Image') {

stage('Test Stage: testing endpoint') {
steps {
container('docker') {
sh 'docker build -t dareyregistry/java-app:latest .'
}
}
}
stage('Login-Into-Docker') {
sh 'docker-compose -f tooling.yml up -d'

script {
while (true) {
def response = httpRequest 'http://localhost:5000'
if (response.status == 200) {
sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin'
}
break
}
}
}
}

stage('Push docker image to docker hub registry') {
when { expression { response.status == 200 } }
steps {
container('docker') {
sh 'docker login -u dareyregistry -p Phartion001ng'
sh 'docker push stlng/tooling-${env.BRANCH_NAME}:${env.BUILD_NUMBER}'
}
}
}
stage('Push-Images-Docker-to-DockerHub') {
steps {
container('docker') {
sh 'docker push dareyregistry/java-app:latest'

stage('Cleaning up') {
steps{
sh 'docker compose -f tooling.yml down'
sh 'docker rmi tooling-${env.BRANCH_NAME}:${env.BUILD_NUMBER}'
}
}
}
}
}

post {
always {
container('docker') {
sh 'docker logout'
}
sh 'docker logout'
}
}
}
}
}
32 changes: 32 additions & 0 deletions Jenkinsfile.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
pipeline {
agent any
options {
buildDiscarder(logRotator(numToKeepStr: '5'))
}
environment {
PATH = '/usr/bin/sh'
DOCKERHUB_CREDENTIALS = credentials('dockerhub')
}
stages {
stage('Build image for toolng-app') {
steps {
sh 'docker build -t stlng/tooling-master:0.0.1 .'
}
}
stage('Login to docker hub') {
steps {
sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin'
}
}
stage('Push docker image to docker hub registry') {
steps {
sh 'docker push stlng/tooling-master:0.0.1'
}
}
}
post {
always {
sh 'docker logout'
}
}
}
73 changes: 73 additions & 0 deletions Jenkinsfile.bk
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
pipeline {
agent {
kubernetes {
yaml '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: maven
image: maven:alpine
command:
- cat
tty: true
- name: docker
image: docker:latest
command:
- cat
tty: true
volumeMounts:
- mountPath: /var/run/docker.sock
name: docker-sock
volumes:
- name: docker-sock
hostPath:
path: /var/run/docker.sock
'''
}
}
stages {
stage('Clone') {
steps {
container('maven') {
git branch: 'main', changelog: false, poll: false, url: 'https://mohdsabir-cloudside@bitbucket.org/mohdsabir-cloudside/java-app.git'
}
}
}
stage('Build-Jar-file') {
steps {
container('maven') {
sh 'mvn package'
}
}
}
stage('Build-Docker-Image') {
steps {
container('docker') {
sh 'docker build -t dareyregistry/java-app:latest .'
}
}
}
stage('Login-Into-Docker') {
steps {
container('docker') {
sh 'docker login -u dareyregistry -p Phartion001ng'
}
}
}
stage('Push-Images-Docker-to-DockerHub') {
steps {
container('docker') {
sh 'docker push dareyregistry/java-app:latest'
}
}
}
}
post {
always {
container('docker') {
sh 'docker logout'
}
}
}
}
61 changes: 61 additions & 0 deletions Jenkinsfile.bk1
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
pipeline {
agent any
options {
buildDiscarder(logRotator(numToKeepStr: '5'))
}
environment {
PATH = '/usr/bin/sh'
DOCKERHUB_CREDENTIALS = credentials('dockerhub')
}
stages {
stage('Build image for tooling-app') {
steps {
sh 'docker build -t stlng/tooling-master:0.0.2 .'
}
}

stage('Build container for tooling-app') {
steps {
sh 'docker compose -f tooling.yml up -d'
}
}

stage('Test Stage') {
steps {
httpRequest url:"http://localhost:5000",
validResponseCodes:'200'

// echo "HTTP response status code: ${status_code}"

// if (status_code != "200") {
// error('URL status different from 200. FAILURE')
// }
}
}

stage('Login to docker hub') {
steps {
sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin'
}
}

stage('Push docker image to docker hub registry') {
steps {
sh 'docker push stlng/tooling-master:0.0.2'
}
}

stage('docker hub logout') {
steps{
sh 'docker logout'
}
}

post {
always {
cleanWs()
sh 'docker compose -f tooling.yml down'
}
}
}
}
1 change: 1 addition & 0 deletions create_user.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE USER ''@'%' IDENTIFIED BY ''; GRANT ALL PRIVILEGES ON * . * TO ''@'%';
10 changes: 10 additions & 0 deletions docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Command 'shell' not found, did you mean:
command 'spell' from deb spell (1.0-24.2)
command 'rshell' from deb pyboard-rshell (0.0.31-0ubuntu1)
command 'bshell' from deb avahi-ui-utils (0.8-5ubuntu5)
command 'jshell' from deb openjdk-11-jdk-headless (11.0.18+10-0ubuntu1~22.04)
command 'jshell' from deb openjdk-17-jdk-headless (17.0.6+10-0ubuntu1~22.04)
command 'jshell' from deb openjdk-18-jdk-headless (18.0.2+9-2~22.04)
command 'jshell' from deb openjdk-19-jdk-headless (19.0.2+7-0ubuntu3~22.04)
command 'shelr' from deb shelr (0.16.3-2.1)
Try: sudo apt install <deb name>
6 changes: 3 additions & 3 deletions html/.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# input your environment variables

MYSQL_IP=mysqlserverhost
MYSQL_USER=Admin
MYSQL_PASS=Admin.com
MYSQL_DBNAME=toolingdb
MYSQL_USER=
MYSQL_PASS=
MYSQL_DBNAME=toolingdb
3 changes: 2 additions & 1 deletion html/db_conn.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@

// enabling environment variable for php


$servername = $_ENV["MYSQL_IP"]; // input servername
$username = $_ENV["MYSQL_USER"]; // input username
$password = $_ENV["MYSQL_PASS"]; //input password
$dbname = $_ENV["MYSQL_DBNAME"]; // input dbname


// Create connection

$conn = new mysqli($servername, $username, $password, $dbname);


// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
Expand Down
1 change: 0 additions & 1 deletion test.txt

This file was deleted.

39 changes: 39 additions & 0 deletions tooling.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: "3.9"
services:
tooling_frontend:
build: .
container_name: tooling
ports:
- "5000:80"
volumes:
- tooling_frontend:/var/www/html
networks:
- tooling_app_network
links:
- db
db:
image: mysql/mysql-server:latest
container_name: mysqlserverhost
ports:
- 3306:3306
restart: always
environment:
# MYSQL_DATABASE: 'toolingdb'
# MYSQL_USER: ''
# MYSQL_PASSWORD: ''
# MYSQL_RANDOM_ROOT_PASSWORD: '1'

MYSQL_DATABASE: '${MYSQL_DBNAME}'
MYSQL_USER: '${MYSQL_USER}'
MYSQL_PASSWORD: '${MYSQL_PASS}'
MYSQL_RANDOM_ROOT_PASSWORD: '1'
volumes:
- db:/var/lib/mysql
networks:
- tooling_app_network
volumes:
tooling_frontend:
db:
networks:
tooling_app_network : {}

Loading