mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-27 09:25:49 +00:00
Jenkins setup
This commit is contained in:
parent
a666c41a62
commit
b5f78e65ca
5 changed files with 42 additions and 41 deletions
25
.github/workflows/docker-image.yml
vendored
25
.github/workflows/docker-image.yml
vendored
|
@ -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
|
|
16
Dockerfile
16
Dockerfile
|
@ -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
10
Dockerfile.build
Normal 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
6
Dockerfile.run
Normal 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
26
Jenkinsfile
vendored
Normal 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'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue