Dockerfile Examples
Organize Dockerfile examples here.
Spring boot application
Version 1: Using JAR file
Create a demo project from Spring Initializr
Building the Java project
# set the version of JDK to 21 by the sdk command (optional) |
Dockerfile
FROM eclipse-temurin:21-jre-alpine |
Building Docker image and running Docker container
docker build --build-arg JAR_FILE=build/libs/\*.jar -t my-spring-boot-app . |
Version 2: Separating dependencies and application resources in a Spring Boot fat JAR file to improve performance
Create a demo project from Spring Initializr
Building the Java project
# set the version of JDK to 21 by the sdk command (optional) |
Dockerfile
FROM eclipse-temurin:21-jre-alpine |
Building Docker image and running Docker container
docker build -t my-spring-boot-app . |
React application
Dockerfile
# Build Stage |
Building Docker image and running Docker container
docker build -t my-react-app . |