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
Empty file modified ex1-shai/bootstrap.sh
100644 → 100755
Empty file.
Empty file modified ex1-shai/checkNcdu.sh
100644 → 100755
Empty file.
5 changes: 1 addition & 4 deletions ex1-shai/checkNginx.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ else
systemctl disable nginx
userdel -r nginx

rm -rf /etc/nginx
rm -rf /var/log/nginx
rm -rf /var/cache/nginx/
rm -rf /usr/lib/systemd/system/nginx.servic
rm -rf /etc/nginx /var/log/nginx /var/cache/nginx /usr/lib/systemd/system/nginx.servic

yum remove -y nginx
elif [[ $answer = "N" ]]; then
Expand Down
5 changes: 1 addition & 4 deletions ex2-shai/bootstrap.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ which git > /dev/null 2>&1
if [[ $? -eq 1 ]]; then
yum install http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm
yum install git
git config --global user.name <Full Name>
git config --global user.email <email address>
else
echo "git installed"
fi
---

which docker > /dev/null 2>&1
if [[ $? -eq 1 ]]; then
Expand All @@ -35,4 +32,4 @@ if [[ $? -eq 1 ]]; then
docker run --name myjenkins -u root -d -p 11000:8080 -v /home/Documents/shai/JenkinsHome:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock jenkins/jenkins
else
echo "jenkins installed"
fi
fi
59 changes: 59 additions & 0 deletions ex3/InstallJenkins.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash

which docker > /dev/null 2>&1
if [[ $? -eq 1 ]]; then
yum update -y
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
echo "Installing docker....."
yum install -y docker-ce docker-ce-cli containerd.io
systemctl enable docker
systemctl start docker

systemctl is-active --quiet docker && echo Docker is running
else
echo "docker installed"
fi

docker container inspect myJenkins > /dev/null 2>&1
if [[ $? -eq 1 ]]; then
echo "Installing jenkins"
mkdir -p /home/shai/Documents/backery/playground/jcasc/ex3/JenkinsHome
chmod 755 /home/shai/Documents/backery/playground/jcasc/ex3/JenkinsHome
cd /home/shai/Documents/backery/playground/jcasc/ex3/

echo "
git:latest
github-api:latest
workflow-aggregator:latest
python:latest
pipeline-github-lib:latest
pipeline-stage-view:latest" > plugins.txt

echo "
unclassified:
location:
url: http://server_ip:8080/
jenkins:
securityRealm:
local:
allowsSignup: false
users:
- id: ${JENKINS_ADMIN_ID}
password: ${JENKINS_ADMIN_PASSWORD}" > casc.yaml

echo "
FROM jenkins/jenkins:lts
COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt
COPY casc.yaml /var/jenkins_home/casc.yaml
ENV CASC_JENKINS_CONFIG /var/jenkins_home/casc.yaml
ENV JAVA_OPTS -Djenkins.install.runSetupWizard=false" > Dockerfile


docker build -t jenkins:jcasc -f Dockerfile .
docker run --name myJenkins -u root -d -p 8080:8080 --env JENKINS_ADMIN_ID=root --env JENKINS_ADMIN_PASSWORD=root -v /home/shai/Documents/backery/playground/jcasc/ex3/JenkinsHome:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock jenkins:jcasc
else
echo "jenkins installed"
fi

29 changes: 29 additions & 0 deletions ex3/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
pipeline {
agent any
environment {
CI = 'true'
}
stages {
stage('Build') {
steps {
println 'Compiling the application!'
}
}
stage("Deploy to master"){
when {
branch 'master'
}
steps {
println 'Deploying to master'
}
}
stage("Deploy to Production"){
when {
branch 'production'
}
steps {
println 'Deploying to production'
}
}
}
}
26 changes: 26 additions & 0 deletions ex4/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM jenkins/jenkins:lts
USER root
RUN apt-get update && \
apt-get -y install apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common && \
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg > /tmp/dkey; apt-key add /tmp/dkey && \
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
$(lsb_release -cs) \
stable" && \
apt-get update && \
apt-get -y install docker-ce
RUN apt-get install -y docker-ce
RUN groupmod -g 993 docker
RUN usermod -a -G docker jenkins
USER jenkins
ENV JAVA_OPTS -Djenkins.install.runSetupWizard=false
ENV CASC_JENKINS_CONFIG /var/jenkins_home/casc.yml
COPY JENKINS_ADMIN_ID /run/secrets/JENKINS_ADMIN_ID
COPY JENKINS_ADMIN_PASSWORD /run/secrets/JENKINS_ADMIN_PASSWORD
COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt
COPY casc.yml /var/jenkins_home/casc.yml
21 changes: 21 additions & 0 deletions ex4/Dockerfile-15-11
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM jenkins/jenkins:lts
USER root
RUN apt-get update && \
apt-get -y install apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common && \
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg > /tmp/dkey; apt-key add /tmp/dkey && \
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
$(lsb_release -cs) \
stable" && \
apt-get update && \
apt-get -y install docker-ce
RUN apt-get install -y docker-ce
RUN usermod -a -G docker jenkins
USER jenkins
ENV JAVA_OPTS -Djenkins.install.runSetupWizard=false
COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt
23 changes: 23 additions & 0 deletions ex4/Dockerfile-bku-14-11
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM jenkins/jenkins:lts
USER root
RUN apt-get update && \
apt-get -y install apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common && \
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg > /tmp/dkey; apt-key add /tmp/dkey && \
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
$(lsb_release -cs) \
stable" && \
apt-get update && \
apt-get -y install docker-ce
RUN apt-get install -y docker-ce
RUN usermod -a -G docker jenkins
USER jenkins
ENV JAVA_OPTS -Djenkins.install.runSetupWizard=false
COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt
COPY casc.yaml /var/jenkins_home/casc.yaml
ENV CASC_JENKINS_CONFIG /var/jenkins_home/casc.yaml
26 changes: 26 additions & 0 deletions ex4/Dockerfile-bku-15-11
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM jenkins/jenkins:lts
USER root
RUN apt-get update && \
apt-get -y install apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common && \
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg > /tmp/dkey; apt-key add /tmp/dkey && \
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
$(lsb_release -cs) \
stable" && \
apt-get update && \
apt-get -y install docker-ce
RUN apt-get install -y docker-ce
RUN groupmod -g 993 docker
RUN usermod -a -G docker jenkins
USER jenkins
ENV JAVA_OPTS -Djenkins.install.runSetupWizard=false
ENV CASC_JENKINS_CONFIG /var/jenkins_home/casc.yml
COPY JENKINS_ADMIN_ID /run/secrets/JENKINS_ADMIN_ID
COPY JENKINS_ADMIN_PASSWORD /run/secrets/JENKINS_ADMIN_PASSWORD
COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt
COPY casc.yaml /var/jenkins_home/casc.yaml
1 change: 1 addition & 0 deletions ex4/JENKINS_ADMIN_ID
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
admin
1 change: 1 addition & 0 deletions ex4/JENKINS_ADMIN_PASSWORD
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
admin
22 changes: 22 additions & 0 deletions ex4/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
pipeline {
agent any
stages {

stage('Build') {
steps {
echo 'Start build'
sh 'docker build -t microblog:latest .'
sh 'docker run --name microblogFromJenkins -d -p 8001:5000 --rm microblog:latest'

}
}
}
post {
success {
echo "Pipeline successful"
}
failure {
echo "The Pipeline failed :("
}
}
}
2 changes: 2 additions & 0 deletions ex4/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker build -t jenkins:jcasc .
docker run --name myJ -u root -d -p 8085:8080 --env JENKINS_ADMIN_ID=admin --env JENKINS_ADMIN_PASSWORD=admin -v /home/shai/Documents/backery/playground/jcasc/JenkinsHomeNew:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock jenkins:jcasc
15 changes: 15 additions & 0 deletions ex4/casc.yaml-bku
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
jenkins:
securityRealm:
local:
allowsSignup: false
users:
- id: ${JENKINS_ADMIN_ID}
password: ${JENKINS_ADMIN_PASSWORD}
authorizationStrategy:
globalMatrix:
permissions:
- "Overall/Administer:admin"
- "Overall/Read:authenticated"
unclassified:
location:
url: http://192.168.131.132:8085/
24 changes: 24 additions & 0 deletions ex4/casc.yaml-bku-15-11
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
jenkins:
securityRealm:
local:
allowsSignup: false
users:
- id: ${JENKINS_ADMIN_ID}
password: ${JENKINS_ADMIN_PASSWORD}
authorizationStrategy:
globalMatrix:
permissions:
- "Overall/Administer:admin"
- "Overall/Read:authenticated"
remotingSecurity:
enabled: true
security:
queueItemAuthenticator:
authenticators:
- global:
strategy: triggeringUsersAuthorizationStrategy
unclassified:
location:
url: http://192.168.131.134:8085/

10 changes: 10 additions & 0 deletions ex4/casc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
unclassified:
location:
url: http://server_ip:8085/
jenkins:
securityRealm:
local:
allowsSignup: false
users:
- id:
password:
7 changes: 7 additions & 0 deletions ex4/plugins.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

git:latest
github-api:latest
workflow-aggregator:latest
python:latest
pipeline-github-lib:latest
pipeline-stage-view:latest
12 changes: 12 additions & 0 deletions ex5/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM python:3.7-alpine
RUN mkdir /app
COPY . /app
WORKDIR /app
ENV FLASK_APP=app.py
ENV FLASK_RUN_HOST=0.0.0.0
RUN apk add --no-cache gcc musl-dev linux-headers
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
EXPOSE 5000
#COPY . .
CMD ["flask", "run"]
8 changes: 8 additions & 0 deletions ex5/api/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import os
from flask import Flask
app = Flask(__name__)
@app.route('/')
def welcome():
return "Start"
if __name__ == '__main__':
app.run(host='0.0.0.0', port=os.getenv('PORT'))
1 change: 1 addition & 0 deletions ex5/api/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flask
35 changes: 35 additions & 0 deletions ex5/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: '3.6'

services:
api:
build: ./api
depends_on:
- db
environment:
STAGE: test
SQLALCHEMY_DATABASE_URI: postgresql+psycopg2://test:test@db/test
networks:
- default
ports:
- 5000:5000
volumes:
- ./app:/usr/src/app/app
- ./migrations:/usr/src/app/migrations
restart: always

db:
environment:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: test
image: postgres:latest
networks:
- default
ports:
- 5406:5432
restart: always
volumes:
- ./postgres-data:/var/lib/postgresql/data
networks:
default:
name: bakery