Docker task

This commit is contained in:
idvylyuk 2024-11-22 16:35:48 +02:00
parent 67513fde53
commit 15d9a664fe
5 changed files with 77 additions and 0 deletions

1
.gitignore vendored
View file

@ -49,3 +49,4 @@ out/
_site/ _site/
*.css *.css
!petclinic.css !petclinic.css
.env

25
Dockerfile Normal file
View 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
View 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
View 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