Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
4166f8a
Update tooling_db_schema.sql
igorsuchilov May 8, 2021
53348e7
testing git connectivity
Tobajoseph007 Jan 17, 2022
5444c8b
deploy to production
Jan 18, 2022
8ddd83b
Implement Quality Gate
Jan 18, 2022
d3293f7
Implement Quality Gate
Jan 18, 2022
3dfce79
deploy to prod
Jan 18, 2022
d2a4b47
deploy to prod
Jan 20, 2022
de92ca5
manual step
Jan 22, 2022
6944208
manual step
Jan 22, 2022
aad5467
manual step
Jan 22, 2022
fc282bb
manual step
Jan 22, 2022
c3903d9
manual build
Jan 22, 2022
afc2d8a
environment variable edited nand composer file added
Tobajoseph007 Jan 22, 2022
e2e6cb6
Merge pull request #7 from darey-devops/toba_branch
Tobajoseph007 Jan 22, 2022
7dd860f
implementing environment variable
Tobajoseph007 Jan 22, 2022
b083d07
jenkinsfile
Jan 22, 2022
a4081be
unit test and quality gate
Jan 22, 2022
cbc879a
unit test and quality gate
Jan 22, 2022
2291230
new feature
Jan 22, 2022
c88d693
new feature
Jan 22, 2022
a3f4d06
new feature
Jan 22, 2022
ca4e9d2
Merge pull request #6 from igorsuchilov/patch-1
darey-io Jan 23, 2022
a498a49
Merge pull request #8 from darey-devops/toba_branch
darey-io Jan 23, 2022
3b6d0f9
added php enviroment variable and php composer
Tobajoseph007 Jan 23, 2022
4a14a7e
fixed servername set globally on Dockerfile
Tobajoseph007 Jan 23, 2022
ee6661e
Merge branch 'master' into toba_branch
Tobajoseph007 Jan 23, 2022
564f7b7
Merge pull request #9 from darey-devops/toba_branch
Tobajoseph007 Jan 23, 2022
4ac59d4
write jenkins script to test for status code 200
somex6 May 25, 2022
2d1d939
fix
somex6 May 25, 2022
ed9eddc
fix #2
somex6 May 25, 2022
ff6cc80
fix #3
somex6 May 25, 2022
3dea221
fix #4
somex6 May 25, 2022
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
13 changes: 12 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
FROM php:7-apache
MAINTAINER Dare dare@zooto.io
LABEL MAINTAINER somex

RUN docker-php-ext-install mysqli
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
COPY apache-config.conf /etc/apache2/sites-available/000-default.conf
COPY start-apache /usr/local/bin
RUN a2enmod rewrite

# Copy application source
COPY html /var/www
# WORKDIR /var/www

# ADD html/tooling_db_schema.sql /docker-entrypoint-initdb.db

RUN chown -R www-data:www-data /var/www

ENV MYSQL_IP=db
ENV MYSQL_USER=somex
ENV MYSQL_PASS=password123
ENV MYSQL_DBNAME=toolingdb

CMD ["start-apache"]
171 changes: 117 additions & 54 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,62 +1,125 @@
pipeline {
agent any

environment
{
PROJECT = 'php-todo'
ECRURL = '704771385539.dkr.ecr.us-east-1.amazonaws.com/php-todo'
DEPLOY_TO = 'development'
}

stages {

stage('Building the software') {
steps {
echo 'Building the software'
sh '''
echo "Building the software"
'''
}
}


stage('Unit Testing') {
steps {
sh '''
echo "Testing the software (Unit Testing)"
'''

sh '''
echo "Step2"
'''
}
}


stage('Deploy to Dev environment') {
when { branch pattern: "^feature.*|^bug.*|^dev", comparator: "REGEXP"}
steps {
sh '''
echo "Deploying the software to Non-Production Environment only from Feature Branch"
'''
}
}

stage('Deploy to Integration environment') {
when {
expression { BRANCH_NAME ==~ /(integration|develop)/ }
stage("Initial cleanup") {
steps {
dir("${WORKSPACE}") {
deleteDir()
}
}
}

stage('Checkout')
{
steps {
checkout([
$class: 'GitSCM',
doGenerateSubmoduleConfigurations: false,
extensions: [],
submoduleCfg: [],
branches: [[name: 'develop']],
userRemoteConfigs: [[url: "https://github.com/somex6/php-todo.git ",credentialsId:'46403133-dd7c-4075-ad1e-090584927bac']]
])

}
}

stage('Build preparations')
{
steps
{
script
{
// calculate GIT lastest commit short-hash
gitCommitHash = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
shortCommitHash = gitCommitHash.take(7)
// calculate a sample version tag
VERSION = shortCommitHash
// set the build display name
currentBuild.displayName = "#${BUILD_ID}-${VERSION}"
IMAGE = "$PROJECT:$VERSION"
}
}
steps {
sh '''
echo "Deploying the software to Integration Environment from Develop branch for further integration tests"
'''
}
}

stage('Run Integration tests') {
when {
expression { BRANCH_NAME ==~ /(integration|develop)/ }
}

stage('Build For Dev Environment') {
when { branch pattern: "^feature.*|^bug.*|^dev", comparator: "REGEXP"}

steps {
echo 'Build Dockerfile....'
script {
sh("eval \$(aws ecr get-login --no-include-email --region us-east-1 | sed 's|https://||')")
// sh "docker build --network=host -t $IMAGE -f deploy/docker/Dockerfile ."
sh "docker build --network=host -t $IMAGE ."
sh "docker-compose -f tooling.yml up -d"
cmd = """
curl -s -X GET -H 'accept: */*' -w '{http_code}' \
'http://localhost:5000'
"""

status_code = sh(script: cmd, returnStdout: true).trim()
// must call trim() to remove the default trailing newline

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

if (status_code != "200") {
error('URL status different of 200. Exiting script.')
}
docker.withRegistry("https://$ECRURL"){
docker.image("$IMAGE").push("staging-$BUILD_NUMBER")
}
}
steps {
sh '''
echo "Run Integration Tests"
'''
}
}

// Next stage Must always be above thsi line
}
}
}

stage('Build For Staging Environment') {
when {
expression { BRANCH_NAME ==~ /(staging|develop)/ }
}
steps {
echo 'Build Dockerfile....'
script {
sh("eval \$(aws ecr get-login --no-include-email --region us-east-1 | sed 's|https://||')")
// sh "docker build --network=host -t $IMAGE -f deploy/docker/Dockerfile ."
sh "docker build --network=host -t $IMAGE ."
docker.withRegistry("https://$ECRURL"){
docker.image("$IMAGE").push("dev-staging-$BUILD_NUMBER")
}
}
}
}


stage('Build For Production Environment') {
when { tag "release-*" }
steps {
echo 'Build Dockerfile....'
script {
sh("eval \$(aws ecr get-login --no-include-email --region us-east-1 | sed 's|https://||')")
// sh "docker build --network=host -t $IMAGE -f deploy/docker/Dockerfile ."
sh "docker build --network=host -t $IMAGE ."
docker.withRegistry("https://$ECRURL"){
docker.image("$IMAGE").push("prod-$BUILD_NUMBER")
}
}
}
}
}

post
{
always
{
sh "docker rmi -f $IMAGE "
}
}
}
4 changes: 2 additions & 2 deletions Jenkinsfile-Sample
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pipeline {
steps {
echo 'Build Dockerfile....'
script {
sh("eval \$(aws ecr get-login --no-include-email --region eu-central-1 | sed 's|https://||')")
sh("eval \$(aws ecr get-login --no-include-email --region us-east-1 | sed 's|https://||')")
// sh "docker build --network=host -t $IMAGE -f deploy/docker/Dockerfile ."
sh "docker build --network=host -t $IMAGE ."
docker.withRegistry("https://$ECRURL"){
Expand Down Expand Up @@ -141,4 +141,4 @@ pipeline {
sh "docker rmi -f $IMAGE "
}
}
}
}
95 changes: 95 additions & 0 deletions Jenkinsfile-sample2
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
pipeline {
agent any

stages {

stage('Building the software') {
steps {
echo 'Building the software'
sh '''
echo "Building the software"
'''
}
}


stage('Unit Testing') {
steps {
sh '''
echo "Testing the software (Unit Testing)"
'''

sh '''
echo "Step2"
'''
}
}

stage('Quality Gate') {
steps {
sh '''
echo "Implementing Quality Gate Checks"
'''
}
}


stage('Deploy to Dev environment') {
when { branch pattern: "^feature.*|^bug.*|^dev", comparator: "REGEXP"}
steps {
sh '''
echo "Deploying the software to Non-Production Environment only from Feature Branch"
'''
}
}

stage('Deploy to Integration environment') {
when {
expression { BRANCH_NAME ==~ /(integration|develop|master)/ }
}
steps {
sh '''
echo "Deploying the software to Integration Environment from Develop branch for further integration tests"
'''
}
}

stage('Run Integration tests') {
when {
expression { BRANCH_NAME ==~ /(integration|develop|master)/ }
}
steps {
sh '''
echo "Run Integration Tests"
'''
}
}


stage('Deploy to pre-production') {
when { buildingTag() }
steps {
sh '''
echo "Deploying the software to Production Environment from Master branch or a Git Tag"
'''
}
}

stage('Deploy to Production') {
when { buildingTag() }
steps {

script {
timeout(time: 10, unit: 'MINUTES') {
input(id: "Deploy Gate", message: "Deploy to production?", ok: 'Deploy')
}
}
sh '''
echo "Deploying the software to Production Environment from Master branch or a Git Tag"
'''
}
}

// Next stage Must always be above thsi line
}
}
4 changes: 2 additions & 2 deletions html/tooling_db_schema.sql → datadump.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ SET time_zone = "+00:00";
-- Database: `toolingdb`
--

CREATE DATABASE toolingdb;
CREATE DATABASE IF NOT EXISTS toolingdb;

Use Toolingdb;
Use toolingdb;
-- --------------------------------------------------------

--
Expand Down
6 changes: 6 additions & 0 deletions html/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# input your environment variables

MYSQL_IP=mysqlserverhost
MYSQL_USER=somex
MYSQL_PASS=password123
MYSQL_DBNAME=toolingdb
5 changes: 5 additions & 0 deletions html/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"vlucas/phpdotenv": "^5.4"
}
}
Loading