mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 14:55:50 +00:00
Implement Docker deployment with Docker Compose
This commit is contained in:
parent
e24a6f6398
commit
c1c7573c87
2 changed files with 43 additions and 19 deletions
10
Dockerfile
Normal file
10
Dockerfile
Normal file
|
@ -0,0 +1,10 @@
|
|||
FROM openjdk:17-jdk-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the application JAR file
|
||||
COPY spring-petclinic-3.3.0-SNAPSHOT.jar /app/spring-petclinic.jar
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
ENTRYPOINT ["java", "-jar", "spring-petclinic.jar"]
|
|
@ -1,25 +1,39 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:8.4
|
||||
app:
|
||||
image: spring-petclinic:latest
|
||||
container_name: app
|
||||
ports:
|
||||
- "3306:3306"
|
||||
- "8080:8080"
|
||||
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:
|
||||
SPRING_DATASOURCE_URL: jdbc:postgresql://db:5432/petclinic
|
||||
SPRING_DATASOURCE_USERNAME: petclinic
|
||||
SPRING_DATASOURCE_PASSWORD: petclinic
|
||||
SPRING_PROFILES_ACTIVE: postgres
|
||||
depends_on:
|
||||
- db
|
||||
networks:
|
||||
- app-network
|
||||
|
||||
db:
|
||||
image: postgres:16.3
|
||||
container_name: db
|
||||
environment:
|
||||
POSTGRES_USER: petclinic
|
||||
POSTGRES_PASSWORD: petclinic
|
||||
POSTGRES_DB: petclinic
|
||||
ports:
|
||||
- "5432:5432"
|
||||
environment:
|
||||
- POSTGRES_PASSWORD=petclinic
|
||||
- POSTGRES_USER=petclinic
|
||||
- POSTGRES_DB=petclinic
|
||||
profiles:
|
||||
- postgres
|
||||
volumes:
|
||||
- db-data:/var/lib/postgresql/data # Volume for PostgreSQL data persistence
|
||||
networks:
|
||||
- app-network
|
||||
|
||||
networks:
|
||||
app-network:
|
||||
name: app-network
|
||||
|
||||
volumes:
|
||||
db-data:
|
||||
name: db-data
|
||||
|
|
Loading…
Reference in a new issue