Skip to content

Deploy #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5b2a01b
Update build-agent.yaml
vinycoolguy2015 Dec 11, 2021
dcd18fd
Update Jenkinsfile
vinycoolguy2015 Dec 11, 2021
4b8d158
Update build-agent.yaml
vinycoolguy2015 Dec 11, 2021
e9949c2
Update Jenkinsfile
vinycoolguy2015 Dec 11, 2021
a6ba831
Update Jenkinsfile
vinycoolguy2015 Dec 14, 2021
181ad4a
Update Jenkinsfile
vinycoolguy2015 Dec 14, 2021
6602738
Update Jenkinsfile
vinycoolguy2015 Dec 14, 2021
5fc17be
Update Jenkinsfile
vinycoolguy2015 Dec 14, 2021
150b1c9
Update Jenkinsfile
vinycoolguy2015 Dec 14, 2021
a2d9d6a
SAST
vinycoolguy2015 Dec 15, 2021
e4c38dc
SCA to Fail
vinycoolguy2015 Dec 15, 2021
6577565
Update Springboot version
vinycoolguy2015 Dec 15, 2021
5a2fdd7
Update Springboot version
vinycoolguy2015 Dec 15, 2021
0c1308d
Update Springboot version
vinycoolguy2015 Dec 15, 2021
70d12ea
Update license approval list
vinycoolguy2015 Dec 15, 2021
d816e6b
Update Dockerfile
vinycoolguy2015 Dec 15, 2021
1c1d51d
Update Dockerfile
vinycoolguy2015 Dec 15, 2021
587823b
Update Dockerfile
vinycoolguy2015 Dec 15, 2021
33f0139
Update Dockerfile
vinycoolguy2015 Dec 15, 2021
7fe77e0
Update Dockerfile
vinycoolguy2015 Dec 15, 2021
935ab78
Update Jenkinsfile
vinycoolguy2015 Dec 15, 2021
21a6383
Update Jenkinsfile
vinycoolguy2015 Dec 15, 2021
f129724
add k8s manifests to deploy dso-demo app
vinycoolguy2015 Dec 23, 2021
4089d87
Update Jenkinsfile
vinycoolguy2015 Dec 23, 2021
b3c8fd7
Update Jenkinsfile
vinycoolguy2015 Dec 23, 2021
79ea8fe
Update pom.xml
vinycoolguy2015 Dec 23, 2021
f7068f5
Update DemoApplication.java
vinycoolguy2015 Dec 23, 2021
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
23 changes: 14 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
FROM maven:3.6-jdk-8

FROM maven:3.8.4-openjdk-17 AS build
WORKDIR /app
COPY . .
RUN mvn package -DskipTests

COPY . .

RUN mvn package -DskipTests && \
mv target/demo-0.0.1-SNAPSHOT.jar /run/demo.jar

FROM openjdk:18-alpine AS run
WORKDIR /run
COPY --from=build /app/target/demo-0.0.1-SNAPSHOT.jar demo.jar
ARG USER=devops
ENV HOME /home/$USER
RUN adduser -D $USER && chown $USER:$USER /run/demo.jar
RUN apk add --no-cache curl
HEALTHCHECK --interval=30s --timeout=10s --retries=2 --start-period=20s \
CMD curl -f http://localhost:8080/ || exit 1
USER $USER
EXPOSE 8080

CMD java -jar /run/demo.jar
CMD java -jar /run/demo.jar
94 changes: 91 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
pipeline {
environment {
ARGO_SERVER = '104.197.60.253:32100'
}
agent {
kubernetes {
yamlFile 'build-agent.yaml'
Expand All @@ -18,7 +21,7 @@ pipeline {
}
}
}
stage('Test') {
stage('Static Analysis') {
parallel {
stage('Unit Tests') {
steps {
Expand All @@ -27,6 +30,60 @@ pipeline {
}
}
}
stage('SCA') {
steps {
container('maven') {
catchError(buildResult: 'SUCCESS', stageResult:'FAILURE') {
sh 'mvn org.owasp:dependency-check-maven:check'
}
}
}
post {
always {
archiveArtifacts allowEmptyArchive: true,artifacts: 'target/dependency-check-report.html', fingerprint:true, onlyIfSuccessful: true
// dependencyCheckPublisher pattern: 'report.xml'
}
}
}
stage('OSS License Checker') {
steps {
container('licensefinder') {
sh 'ls -al'
sh '''#!/bin/bash --login
/bin/bash --login
rvm use default
gem install license_finder
license_finder
'''
}
}
}
stage('Generate SBOM') {
steps {
container('maven') {
sh 'mvn org.cyclonedx:cyclonedx-maven-plugin:makeAggregateBom'
}
}
post {
success {
//dependencyTrackPublisher projectName:'sample-spring-app', projectVersion: '0.0.1', artifact:'target/bom.xml', autoCreateProjects: true, synchronous: true
archiveArtifacts allowEmptyArchive: true,artifacts: 'target/bom.xml', fingerprint: true,onlyIfSuccessful: true
}
}
}
}
}
stage('SAST') {
steps {
container('slscan') {
sh 'scan --type java,depscan --build'
}
}
post {
success {
archiveArtifacts allowEmptyArchive: true,
artifacts: 'reports/*', fingerprint: true, onlyIfSuccessful:true
}
}
}
stage('Package') {
Expand All @@ -38,13 +95,44 @@ pipeline {
}
}
}
stage('Build with Kaniko') {
steps {
container('kaniko') {
sh '/kaniko/executor -f `pwd`/Dockerfile -c `pwd` --insecure --skip-tls-verify --cache=true --destination=docker.io/vinycoolguy/dsodemo'
}
}
}
}
}

stage('Image Analysis') {
parallel {
stage('Image Linting') {
steps {
container('docker-tools') {
sh 'dockle docker.io/vinycoolguy/dsodemo'
}
}
}
stage('Image Scan') {
steps {
container('docker-tools') {
sh 'trivy image vinycoolguy/dsodemo'
}
}
}
}
}

stage('Deploy to Dev') {
environment {
AUTH_TOKEN = credentials('argocd-jenkins-deployer-token')
}
steps {
// TODO
sh "echo done"
container('docker-tools') {
sh 'docker run -t schoolofdevops/argocd-cli argocd app sync dso-demo --insecure --server $ARGO_SERVER --auth-token $AUTH_TOKEN'
sh 'docker run -t schoolofdevops/argocd-cli argocd app wait dso-demo --health --timeout 300 --insecure --server $ARGO_SERVER --auth-token $AUTH_TOKEN'
}
}
}
}
Expand Down
24 changes: 24 additions & 0 deletions build-agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ spec:
name: docker-sock
- mountPath: /tmp/trivycache/
name: trivycache
- name: slscan
image: shiftleft/sast-scan
imagePullPolicy: Always
command:
- cat
tty: true
- name: kaniko
image: gcr.io/kaniko-project/executor:v1.6.0-debug
imagePullPolicy: Always
command:
- sleep
args:
- 99d
volumeMounts:
- name: jenkins-docker-cfg
mountPath: /kaniko/.docker
- name: trufflehog
image: rmkanda/trufflehog
command:
Expand All @@ -43,3 +59,11 @@ spec:
- name: trivycache
hostPath:
path: /tmp/trivycache/
- name: jenkins-docker-cfg
projected:
sources:
- secret:
name: regcred
items:
- key: .dockerconfigjson
path: config.json
26 changes: 26 additions & 0 deletions deploy/dso-demo-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: dso-demo
name: dso-demo
spec:
replicas: 1
selector:
matchLabels:
app: dso-demo
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: dso-demo
spec:
containers:
- image: vinycoolguy/dsodemo
name: dsodemo
ports:
- containerPort: 8080
resources: {}
status: {}
19 changes: 19 additions & 0 deletions deploy/dso-demo-svc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
app: dso-demo
name: dso-demo
spec:
ports:
- name: "8080"
nodePort: 30080
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: dso-demo
type: NodePort
status:
loadBalancer: {}
10 changes: 8 additions & 2 deletions doc/dependency_decisions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
- :who:
:why:
:versions:
- 1.2.3
- 1.2.6
:when: 2020-05-31 15:28:30.302764000 Z
- - :approve
- logback-classic
- :who:
:why:
:versions:
- 1.2.3
- 1.2.6
:when: 2020-05-31 15:29:03.621478000 Z
- - :approve
- jakarta.xml.bind-api
Expand All @@ -70,3 +70,9 @@
:versions:
- 1.3.5
:when: 2020-05-31 15:29:53.045616000 Z
- - :permit
- New BSD
- :who:
:why:
:versions: []
:when: 2020-09-29
6 changes: 5 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.3</version>
<version>2.5.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.demo</groupId>
Expand All @@ -16,6 +16,7 @@

<properties>
<java.version>1.8</java.version>
<log4j2.version>2.17.0</log4j2.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -47,6 +48,9 @@
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>6.1.1</version>
<configuration>
<failBuildOnCVSS>8</failBuildOnCVSS>
</configuration>
<executions>
<execution>
<goals>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/demo/demo/DemoApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class DemoApplication {

@GetMapping("/")
public String available() {
return "<html><body><h1>DevSecOps Demo</body></h1></html>";
return "<html><body><h1>DevSecOps Demo Updated</body></h1></html>";
}

public static void main(String[] args) {
Expand Down