mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-18 05:25:50 +00:00
add docker files
This commit is contained in:
parent
3940742429
commit
518643c7af
5 changed files with 45 additions and 17 deletions
3
.env
Normal file
3
.env
Normal file
|
@ -0,0 +1,3 @@
|
|||
DB_USERNAME=petclinic
|
||||
DB_PASSWORD=petclinic
|
||||
DB_ROOT_PASSWORD=root_petclinic
|
7
Dockerfile
Normal file
7
Dockerfile
Normal file
|
@ -0,0 +1,7 @@
|
|||
FROM eclipse-temurin:21-jdk-jammy
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY target/spring-petclinic-*.jar /app/spring-petclinic.jar
|
||||
|
||||
CMD ["java", "-jar", "spring-petclinic.jar"]
|
12
Dockerfile.multi
Normal file
12
Dockerfile.multi
Normal file
|
@ -0,0 +1,12 @@
|
|||
FROM eclipse-temurin:21-jdk-jammy as build
|
||||
WORKDIR /app
|
||||
COPY .mvn/ .mvn
|
||||
COPY mvnw pom.xml ./
|
||||
RUN ./mvnw dependency:resolve
|
||||
COPY src ./src
|
||||
RUN ./mvnw package
|
||||
|
||||
FROM eclipse-temurin:21-jre-alpine
|
||||
COPY --from=build /app/target/spring-petclinic-*.jar /spring-petclinic.jar
|
||||
EXPOSE 8080
|
||||
CMD ["java", "-jar", "spring-petclinic.jar"]
|
|
@ -1,21 +1,27 @@
|
|||
version: "3"
|
||||
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:9.1
|
||||
petclinic:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.multi
|
||||
ports:
|
||||
- "3306:3306"
|
||||
- 8080:8080
|
||||
environment:
|
||||
- MYSQL_URL=jdbc:mysql://mysqlserver/petclinic
|
||||
- SERVER_PORT=8080
|
||||
depends_on:
|
||||
- mysqlserver
|
||||
mysqlserver:
|
||||
image: mysql:8.0
|
||||
ports:
|
||||
- 3306:3306
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=
|
||||
- MYSQL_ALLOW_EMPTY_PASSWORD=true
|
||||
- MYSQL_USER=petclinic
|
||||
- MYSQL_PASSWORD=petclinic
|
||||
- MYSQL_DATABASE=petclinic
|
||||
- MYSQL_USER=${DB_USERNAME}
|
||||
- MYSQL_PASSWORD=${DB_PASSWORD}
|
||||
- MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
|
||||
volumes:
|
||||
- "./conf.d:/etc/mysql/conf.d:ro"
|
||||
postgres:
|
||||
image: postgres:17.0
|
||||
ports:
|
||||
- "5432:5432"
|
||||
environment:
|
||||
- POSTGRES_PASSWORD=petclinic
|
||||
- POSTGRES_USER=petclinic
|
||||
- POSTGRES_DB=petclinic
|
||||
- mysql_data:/var/lib/mysql
|
||||
volumes:
|
||||
mysql_data:
|
Loading…
Reference in a new issue