Created
September 17, 2024 07:08
-
-
Save thanoojgithub/f152a72a3cf514817cd9dab235773996 to your computer and use it in GitHub Desktop.
Docker Compose for Spring Boot with MySQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
db: | |
image: mysql:latest | |
environment: | |
- MYSQL_ROOT_PASSWORD=root | |
- MYSQL_DATABASE=mydb | |
- MYSQL_PASSWORD=secret | |
- MYSQL_USER=myuser | |
restart: always | |
ports: | |
- '3306:3306' | |
volumes: | |
- data:/data/customer | |
networks: | |
- bootApp | |
app: | |
depends_on: | |
- db | |
build: | |
context: . | |
dockerfile: Dockerfile | |
ports: | |
- '8089:8089' | |
environment: | |
- spring.jpa.hibernate.ddl-auto=update | |
- spring.datasource.url=jdbc:mysql://db:3306/mydb?createDatabaseIfNotExist=true | |
- spring.datasource.username=myuser | |
- spring.datasource.password=secret | |
- spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver | |
- spring.jpa.show-sql=true | |
- spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect | |
volumes: | |
- .m2:/root/.m2 | |
networks: | |
- bootApp | |
volumes: | |
data: | |
driver: local | |
.m2: | |
driver: local | |
networks: | |
bootApp: | |
driver: bridge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment