instruction: Create a Dockerfile for multi-stage build with production best practices
output: ```dockerfile
  from the build stage. Finally, it defines the runtime configuration (using CMD or ENTRYPOINT) for starting your application.Try it outIn this hands-on guide, you'll unlock the power of multi-stage builds to create lean and efficient Docker images for a sample Java application. You'll use a simple âHello Worldâ Spring Boot-based application built with Maven as your example.Download and install Docker Desktop.Open this pre-initialized project to generate a ZIP file. Hereâs how that looks:
  Spring Initializr is a quickstart generator for Spring projects. It provides an extensible API to generate JVM-based projects with implementations for several common concepts â like basic language generation for Java, Kotlin, and Groovy.Select Generate to create and download the zip file for this project.For this demonstration, youâve paired Maven build automation with Java, a Spring Web dependency, and Java 21 for your metadata.Navigate the project directory. Once you unzip the file, you'll see the following project directory structure:
  
  spring-boot-docker
  âââ HELP.md
  âââ mvnw
  âââ mvnw.cmd
  âââ pom.xml
  âââ src
   âââ main
   â âââ java
   â â âââ com
   â â âââ example
   â â âââ spring_boot_docker
   â â âââ SpringBootDockerApplication.java
   â âââ resources
   â âââ application.properties
   â âââ static
   â âââ templates
   âââ test
   âââ java
   âââ com
   âââ example
   âââ spring_boot_docker
   âââ SpringBootDockerApplicationTests.java
  
  15 directories, 7 filesThe src/main/java directory contains your project's source code, the src/test/java directorycontains the test source, and the pom.xml file is your projectâs Project Object Model (POM).The pom.xml file is the core of a Maven project's configuration. It's a single configuration file thatcontains most of the information needed to build a customized project. The POM is huge and can seemdaunting. Thankfully, you don't yet need to understand every intricacy to use it effectively.Create a RESTful web service that displays "Hello World!".Under the src/main/java/com/example/spring_boot_docker/ directory, you can modify yourSpringBootDockerApplication.java file with the following content:
  
  package com.example.spring_boot_docker;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RestController;
  
  @RestController
  @SpringBootApplication
  public class SpringBootDockerApplication {
  
   @RequestMapping("/")
   public String home() {
   return "Hello World";
   }
  
  	public static void main(String[] args) {
  		SpringApplication.run(SpringBootDockerApplication.class, args);
  	}
  
  }The SpringbootDockerApplication.java file starts by declaring your com.example.spring_boot_docker package and importing necessary Spring frameworks. This Java file creates a simple Spring Boot web application that responds with "Hello World" when a user visits its homepage.Create the DockerfileNow that you have the project, youâre ready to create the Dockerfile.Create a file named Dockerfile in the same folder that contains all the other folders and files (like src, pom.xml, etc.).In the Dockerfile, define your base image by adding the following line:
  ```