Step 1: Create project using spring.io
curl https://start.spring.io/starter.tgz -d type=gradle-project \
-d language=java \
-d bootVersion=2.6.5 \
-d baseDir=helloG \
-d groupId=com.example.hello \
-d artifactId=helloG \
-d description=Demo%20project%20for%20Spring%20Boot \
-d packageName=com.example.hello.helloG \
-d packaging=jar \
-d javaVersion=11 \
-d dependencies=devtools,web | tar -xzvf -
Then follow steps
Step 2:
./gradlew clean build
Check if the project is build properly.
java -jar build/libs/helloG-0.0.1-SNAPSHOT.jar
Step 3: Create Docker File
FROM adoptopenjdk/openjdk11:alpine
VOLUME /tmp
EXPOSE 9222
ARG JAR_FILE=./build/libs/helloG-0.0.1-SNAPSHOT.jar
COPY ${JAR_FILE} helloG-app.jar
ENTRYPOINT ["java","-jar","helloG-app.jar"]
Step 4.1:: Create docker image with tag [-t]
docker build -f Dockerfile -t hellog .
Step 4.2:: Check docker image proper or not
docker images
docker run -it --rm -p 8080:8080 hellog