mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2026-02-04 21:31:11 +00:00
Add Docker Module Files
This commit is contained in:
parent
f25d859dc1
commit
fb1870c4c6
4 changed files with 48 additions and 17 deletions
6
.env.example
Normal file
6
.env.example
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
MYSQL_DATABASE=db_name
|
||||
MYSQL_USER=db_user
|
||||
MYSQL_PASSWORD=db_password
|
||||
MYSQL_ROOT_PASSWORD=root_password
|
||||
|
||||
SPRING_DATASOURCE_URL=jdbc:mysql://db:3306/db_name
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -46,3 +46,4 @@ out/
|
|||
_site/
|
||||
*.css
|
||||
!petclinic.css
|
||||
.env
|
||||
17
Dockerfile
Normal file
17
Dockerfile
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# STAGE 1: Build
|
||||
FROM gradle:8.14.2-jdk17 AS builder
|
||||
|
||||
WORKDIR /build
|
||||
COPY . .
|
||||
RUN gradle clean build -x test
|
||||
|
||||
RUN cp /build/target/spring-petclinic-*.jar /build/app.jar
|
||||
|
||||
# STAGE 2: Runtime
|
||||
FROM eclipse-temurin:17-jre-jammy
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=builder /build/app.jar app.jar
|
||||
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["java", "-jar", "app.jar"]
|
||||
|
|
@ -1,21 +1,28 @@
|
|||
services:
|
||||
mysql:
|
||||
image: mysql:9.5
|
||||
ports:
|
||||
- "3306:3306"
|
||||
db:
|
||||
image: mysql:8.0
|
||||
container_name: petclinic-db
|
||||
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"
|
||||
postgres:
|
||||
image: postgres:18.1
|
||||
MYSQL_DATABASE: ${MYSQL_DATABASE}
|
||||
MYSQL_USER: ${MYSQL_USER}
|
||||
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
|
||||
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
|
||||
healthcheck:
|
||||
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
app:
|
||||
build: .
|
||||
container_name: petclinic-app
|
||||
ports:
|
||||
- "5432:5432"
|
||||
- "9090:8080"
|
||||
environment:
|
||||
- POSTGRES_PASSWORD=petclinic
|
||||
- POSTGRES_USER=petclinic
|
||||
- POSTGRES_DB=petclinic
|
||||
SPRING_PROFILES_ACTIVE: mysql
|
||||
SPRING_DATASOURCE_URL: ${SPRING_DATASOURCE_URL}
|
||||
SPRING_DATASOURCE_USERNAME: ${MYSQL_USER}
|
||||
SPRING_DATASOURCE_PASSWORD: ${MYSQL_PASSWORD}
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
Loading…
Add table
Add a link
Reference in a new issue