Jenkins setup

This commit is contained in:
hllvc 2021-07-10 21:51:31 +02:00
parent a666c41a62
commit b5f78e65ca
5 changed files with 42 additions and 41 deletions

View file

@ -1,25 +0,0 @@
name: Docker Image CI
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build -t hllvc/spring-petclinic .
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push image to Docker Hub
run: docker push hllvc/spring-petclinic:latest

View file

@ -1,16 +0,0 @@
FROM openjdk:8-jdk-alpine AS build
WORKDIR /build
COPY .mvn .mvn
COPY mvnw .
COPY mvnw.cmd .
COPY pom.xml .
RUN ./mvnw -B -e dependency:go-offline
COPY src src
RUN ./mvnw package
FROM openjdk:8-jre-alpine
EXPOSE 8080
ENTRYPOINT [ "java" ]
CMD [ "-jar", "-Dspring.profiles.active=mysql" ,"app.jar" ]
COPY --from=build /build/target/*.jar /app/app.jar
WORKDIR /app

10
Dockerfile.build Normal file
View file

@ -0,0 +1,10 @@
FROM openjdk:8-jdk-alpine
VOLUME [ "/app" ]
WORKDIR /app
COPY .mvn .mvn
COPY mvnw .
COPY mvnw.cmd .
COPY pom.xml .
RUN ./mvnw -B -e dependency:go-offline
COPY src src
RUN ./mvnw package

6
Dockerfile.run Normal file
View file

@ -0,0 +1,6 @@
FROM openjdk:8-jre-alpine
VOLUME [ "/app" ]
WORKDIR /app
EXPOSE 8080
ENTRYPOINT [ "java" ]
CMD [ "-jar", "-Dspring.profiles.active=mysql" ,"app.jar" ]

26
Jenkinsfile vendored Normal file
View file

@ -0,0 +1,26 @@
pipeline {
stages {
stage('Build') {
agent {
dockerfile {
filename 'Dockerfile.build'
dir '.'
label 'petclinic-build'
args '-v $HOME/.m2:/root/.m2 -v ./app:/root/app'
}
}
}
stage('Run') {
agent {
dockerfile {
filename 'Dockerfile.run'
label 'petclinic-run'
args '-v $HOME/.m2:/root/.m2 -v ./app:/root/app'
}
}
}
}
}