forked from jenkins-docs/simple-java-maven-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated jenkins files and added docker files
- Loading branch information
Johnny Truong
committed
Jan 23, 2023
1 parent
51d5f81
commit dd14fb3
Showing
4 changed files
with
108 additions
and
4 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
|