This project includes a multi-stage Dockerfile and a Docker Compose setup for containerized development and deployment.
- Base Image: Uses
eclipse-temurin:17-jdkfor building andeclipse-temurin:17-jrefor running (Java 17 required). - Build Tool: Uses the Maven Wrapper (
mvnw) included in the project for building the application. - Ports: The application exposes port 8080 (default for Spring Boot).
- No required environment variables are set by default in the Dockerfile or Compose file.
- If you need to provide environment variables, you can uncomment and use the
env_filesection indocker-compose.yml.
-
Build and start the application:
docker compose up --build
This will build the image using the provided Dockerfile and start the
java-appservice. -
Access the application:
- The application will be available at http://localhost:8080
- The Dockerfile creates a non-root user (
appuser) for running the application securely. - JVM options are set for container awareness:
JAVA_OPTS="-XX:MaxRAMPercentage=80.0"(can be overridden if needed). - If your application requires additional services (e.g., a database), you can extend the
docker-compose.ymlby uncommenting and configuring the relevant sections.
- java-app:
8080(host) →8080(container)
If you add external dependencies (like a database), update the docker-compose.yml and this section accordingly.