mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 06:45:50 +00:00
add jenkinsfile, dockerfile
This commit is contained in:
parent
317562a170
commit
821eaf4580
3 changed files with 75 additions and 21 deletions
14
Dockerfile
Normal file
14
Dockerfile
Normal file
|
@ -0,0 +1,14 @@
|
|||
# FROM openjdk:17-jdk-alpine
|
||||
# WORKDIR /app
|
||||
# COPY target/spring-petclinic*.jar app.jar
|
||||
# ENTRYPOINT ["java", "-jar", "app.jar"]
|
||||
|
||||
FROM maven:3.8.3-openjdk-17-slim AS builder
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN mvn package -DskipTests
|
||||
|
||||
|
||||
FROM gcr.io/distroless/java17
|
||||
COPY --from=builder /app/target/spring-petclinic*.jar /app/app.jar
|
||||
CMD ["app.jar"]
|
|
@ -1,25 +1,56 @@
|
|||
# services:
|
||||
# mysql:
|
||||
# image: mysql:9.1
|
||||
# ports:
|
||||
# - "3306:3306"
|
||||
# environment:
|
||||
# - MYSQL_ROOT_PASSWORD=
|
||||
# - MYSQL_ALLOW_EMPTY_PASSWORD=true
|
||||
# - MYSQL_USER=petclinic
|
||||
# - MYSQL_PASSWORD=petclinic
|
||||
# - MYSQL_DATABASE=petclinic
|
||||
# volumes:
|
||||
# - "./conf.d:/etc/mysql/conf.d:ro"
|
||||
# profiles:
|
||||
# - mysql
|
||||
# postgres:
|
||||
# image: postgres:17.0
|
||||
# ports:
|
||||
# - "5432:5432"
|
||||
# environment:
|
||||
# - POSTGRES_PASSWORD=petclinic
|
||||
# - POSTGRES_USER=petclinic
|
||||
# - POSTGRES_DB=petclinic
|
||||
# profiles:
|
||||
# - postgres
|
||||
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:9.1
|
||||
ports:
|
||||
- "3306:3306"
|
||||
db:
|
||||
image: postgres:13
|
||||
container_name: spring-petclinic-db
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=
|
||||
- MYSQL_ALLOW_EMPTY_PASSWORD=true
|
||||
- MYSQL_USER=petclinic
|
||||
- MYSQL_PASSWORD=petclinic
|
||||
- MYSQL_DATABASE=petclinic
|
||||
POSTGRES_USER: petclinic
|
||||
POSTGRES_PASSWORD: petclinic
|
||||
POSTGRES_DB: petclinic
|
||||
ports:
|
||||
- "15432:5432"
|
||||
volumes:
|
||||
- "./conf.d:/etc/mysql/conf.d:ro"
|
||||
profiles:
|
||||
- mysql
|
||||
postgres:
|
||||
image: postgres:17.0
|
||||
ports:
|
||||
- "5432:5432"
|
||||
- db-data:/var/lib/postgresql/data
|
||||
|
||||
app:
|
||||
image: spring-petclinic:multistage
|
||||
environment:
|
||||
- POSTGRES_PASSWORD=petclinic
|
||||
- POSTGRES_USER=petclinic
|
||||
- POSTGRES_DB=petclinic
|
||||
profiles:
|
||||
- postgres
|
||||
SPRING_PROFILES_ACTIVE: postgres
|
||||
SPRING_DATASOURCE_URL: jdbc:postgresql://db:5432/petclinic
|
||||
SPRING_DATASOURCE_USERNAME: petclinic
|
||||
SPRING_DATASOURCE_PASSWORD: petclinic
|
||||
ports:
|
||||
- "8080:8080"
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
volumes:
|
||||
db-data:
|
||||
|
||||
|
|
9
dockerfile-multistage
Normal file
9
dockerfile-multistage
Normal file
|
@ -0,0 +1,9 @@
|
|||
FROM maven:3.8.3-openjdk-17-slim AS builder
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN mvn package -DskipTests
|
||||
|
||||
|
||||
FROM gcr.io/distroless/java17
|
||||
COPY --from=builder /app/target/spring-petclinic*.jar /app/app.jar
|
||||
CMD ["app.jar"]
|
Loading…
Reference in a new issue