Skip to content

Commit

Permalink
updated jenkins files and added docker files
Browse files Browse the repository at this point in the history
  • Loading branch information
Johnny Truong committed Jan 23, 2023
1 parent 51d5f81 commit dd14fb3
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 4 deletions.
Empty file added .dockerignore
Empty file.
46 changes: 46 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Use Maven base image
FROM maven:3.8.6-ibmjava-8 as build

# Copy source code
COPY . /app

# Build application
RUN mvn -f /app/pom.xml clean install

# Use Jenkins base image
FROM jenkins/jenkins:lts

USER root

# install wget and tools
RUN apt-get update && apt-get install -y wget && apt-get install -y software-properties-common

## INSTALL MAVEN ON JENKINS PROCESS

# get maven 3.8.6
RUN wget --no-verbose -O /tmp/apache-maven-3.8.6-bin.tar.gz https://repo.huaweicloud.com/apache/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz

# install maven
RUN tar xzf /tmp/apache-maven-3.8.6-bin.tar.gz -C /opt/
RUN ln -s /opt/apache-maven-3.8.6 /opt/maven
RUN ln -s /opt/maven/bin/mvn /usr/local/bin
RUN rm -f /tmp/apache-maven-3.8.6-bin.tar.gz
ENV MAVEN_HOME /opt/maven

RUN chown -R jenkins:jenkins /opt/maven

## SET JAVA 8 PROCESS
RUN apt-add-repository 'deb http://security.debian.org/debian-security stretch/updates main'
RUN apt-get update && apt-get install -y openjdk-8-jdk
RUN update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64

# remove download archive files
RUN apt-get clean

USER jenkins

# Copy built application from the first stage
COPY --from=build /app/target /prometheus-jenkins

62 changes: 62 additions & 0 deletions jenkins.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
version: '3'
services:
jenkins-certs:
image: docker:20.10.9-dind
volumes:
- type: bind
source: C:/Dev/Jenkins/jenkins-acbis/volumes/jenkins/certs
target: /certs/client
- type: bind
source: C:/Dev/Jenkins/jenkins-acbis/volumes/jenkins/data
target: /var/jenkins_home
privileged: true
networks:
jenkins:
# alternative hostnames
aliases: ["docker"]
environment:
DOCKER_TLS_CERTDIR: /certs
TZ: Europe/Berlin
container_name: jenkins-cert
deploy:
resources:
limits:
cpus: "2"
memory: 512M
jenkins:
build:
context: .
ports:
- published: 9000
target: 8080
depends_on: ["jenkins-certs"]
volumes:
- type: bind
source: C:/Dev/Jenkins/jenkins-acbis/volumes/jenkins/certs
target: /certs/client
read_only: true
- type: bind
source: C:/Dev/Jenkins/jenkins-acbis/volumes/jenkins/data
target: /var/jenkins_home
- type: bind
source: .
# siehe "Repository URL" in der Job-Definition
target: /git-repository/prometheus
read_only: true
networks: ["jenkins"]
environment:
DOCKER_HOST: tcp://docker:2376
DOCKER_CERT_PATH: /certs/client
DOCKER_TLS_VERIFY: 1
TZ: Europe/Berlin
container_name: jenkins
hostname: jenkins
#deploy:
# resources:
# limits:
# cpus: "2"
# memory: 4096M
volumes:
jenkins_home:
networks:
jenkins: {}
4 changes: 0 additions & 4 deletions jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
pipeline {
agent any

tools {
maven 'maven-3.8.6'
}

stages {
stage('Build') {
steps {
Expand Down

0 comments on commit dd14fb3

Please sign in to comment.