Skip to content

Conversation

@medd911
Copy link

@medd911 medd911 commented Jul 30, 2024

The solution involved creating a Dockerfile to containerize the Spring Boot application and a docker-compose.yml file to manage both the application and the MySQL database. The Dockerfile handles the build and run stages, while the Docker Compose file orchestrates the multi-container setup, ensuring the services are correctly configured and networked. This setup allows for easy deployment and management of the application in a containerized environment.

Copy link
Owner

@CodelineAtyab CodelineAtyab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check comments and make changes accordingly

ENV SPRING_JPA_SHOW_SQL=true

# Run the Spring Boot application
ENTRYPOINT ["sh", "-c", "java -jar /app/rihal-0.0.1-SNAPSHOT.jar || (echo 'Application failed, sleeping indefinitely' && sleep infinity)"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually we want a container to stop if Java application fails to run. In this case if the application doesn't run then the container would still be up which might cause confusion until someone looks at the logs.
Please share some thoughts about this ?

environment:
SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3307/usersystem?useSSL=false&serverTimezone=UTC&createDatabaseIfNotExist=true&allowPublicKeyRetrieval=true
SPRING_DATASOURCE_USERNAME: root
SPRING_DATASOURCE_PASSWORD: root
Copy link
Owner

@CodelineAtyab CodelineAtyab Aug 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its very important not to expose any password in code changes pushed to GitHub.
Using the .env file can help solve these issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants