mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 06:45:50 +00:00
Docker task
This commit is contained in:
parent
67513fde53
commit
15d9a664fe
5 changed files with 77 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -49,3 +49,4 @@ out/
|
||||||
_site/
|
_site/
|
||||||
*.css
|
*.css
|
||||||
!petclinic.css
|
!petclinic.css
|
||||||
|
.env
|
25
Dockerfile
Normal file
25
Dockerfile
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
FROM maven:3.9.9-eclipse-temurin-17-alpine AS builder
|
||||||
|
|
||||||
|
WORKDIR /petclinic-app
|
||||||
|
COPY pom.xml ./
|
||||||
|
|
||||||
|
RUN mvn dependency:go-offline -B
|
||||||
|
|
||||||
|
COPY src/ ./src/
|
||||||
|
RUN mvn clean package -DskipTests
|
||||||
|
|
||||||
|
FROM eclipse-temurin:17-jdk-alpine AS jre-builder
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY --from=builder /petclinic-app/target/*.jar /app/petclinic.jar
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
CMD [ "java", "-jar", "/app/petclinic.jar" ]
|
||||||
|
|
||||||
|
# ||| potential upgrade:
|
||||||
|
# adding user
|
||||||
|
# .dockerignore don't need -> COPY only what needed
|
||||||
|
# mount .m2 repository
|
||||||
|
|
||||||
|
|
10
Simple_Dockerfile
Normal file
10
Simple_Dockerfile
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
FROM eclipse-temurin:17-jre-alpine AS jre-builder
|
||||||
|
|
||||||
|
WORKDIR /petclinic-app
|
||||||
|
|
||||||
|
ARG JAR_FILE=target/*.jar
|
||||||
|
COPY ${JAR_FILE} /petclinic-app/spring-app.jar
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
CMD ["java", "-jar", "/petclinic-app/spring-app.jar"]
|
41
compose.yaml
Normal file
41
compose.yaml
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
services:
|
||||||
|
petclinic-db:
|
||||||
|
image: postgres:14-alpine
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
volumes:
|
||||||
|
- postgres-data:/var/lib/postgresql/data
|
||||||
|
environment:
|
||||||
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||||
|
- POSTGRES_USER=${POSTGRES_USER}
|
||||||
|
- POSTGRES_DB=${POSTGRES_DB}
|
||||||
|
networks:
|
||||||
|
- petclinic-network
|
||||||
|
profiles:
|
||||||
|
- postgres
|
||||||
|
|
||||||
|
petclinic-web-app:
|
||||||
|
image: spring-petclinic:build-4.0.1-SNAPSHOT
|
||||||
|
depends_on:
|
||||||
|
- petclinic-db
|
||||||
|
environment:
|
||||||
|
- SPRING_DATASOURCE_URL=${SPRING_DATASOURCE_URL}
|
||||||
|
- SPRING_DATASOURCE_USERNAME=${SPRING_DATASOURCE_USERNAME}
|
||||||
|
- SPRING_DATASOURCE_PASSWORD=${SPRING_DATASOURCE_PASSWORD}
|
||||||
|
- SPRING_PROFILES_ACTIVE=postgres
|
||||||
|
deploy:
|
||||||
|
replicas: 1
|
||||||
|
ports:
|
||||||
|
- "8080:8080"
|
||||||
|
networks:
|
||||||
|
- petclinic-network
|
||||||
|
profiles:
|
||||||
|
- postgres
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
postgres-data:
|
||||||
|
driver: local
|
||||||
|
|
||||||
|
networks:
|
||||||
|
petclinic-network:
|
||||||
|
driver: bridge
|
Loading…
Reference in a new issue