add jenkinsfile, dockerfile

This commit is contained in:
Botoi Adrian 2024-11-22 12:37:14 +02:00
parent 317562a170
commit 821eaf4580
3 changed files with 75 additions and 21 deletions

14
Dockerfile Normal file
View 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"]

View file

@ -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: services:
mysql: db:
image: mysql:9.1 image: postgres:13
ports: container_name: spring-petclinic-db
- "3306:3306"
environment: environment:
- MYSQL_ROOT_PASSWORD= POSTGRES_USER: petclinic
- MYSQL_ALLOW_EMPTY_PASSWORD=true POSTGRES_PASSWORD: petclinic
- MYSQL_USER=petclinic POSTGRES_DB: petclinic
- MYSQL_PASSWORD=petclinic ports:
- MYSQL_DATABASE=petclinic - "15432:5432"
volumes: volumes:
- "./conf.d:/etc/mysql/conf.d:ro" - db-data:/var/lib/postgresql/data
profiles:
- mysql app:
postgres: image: spring-petclinic:multistage
image: postgres:17.0
ports:
- "5432:5432"
environment: environment:
- POSTGRES_PASSWORD=petclinic SPRING_PROFILES_ACTIVE: postgres
- POSTGRES_USER=petclinic SPRING_DATASOURCE_URL: jdbc:postgresql://db:5432/petclinic
- POSTGRES_DB=petclinic SPRING_DATASOURCE_USERNAME: petclinic
profiles: SPRING_DATASOURCE_PASSWORD: petclinic
- postgres ports:
- "8080:8080"
depends_on:
- db
volumes:
db-data:

9
dockerfile-multistage Normal file
View 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"]