This is an article related to four knowledge points, namely java, docker, springboot and gradle. We hope to use the springboot framework in the java environment to build the project through gradle, and then deploy and run the project in the docker container !
- Java runtime
- springboot open source scaffolding
- The most popular project build tool for gradle
- Docker's most popular container product
development process
A build.gradle file
dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") classpath('se.transmode.gradle:gradle-docker:1.2') } apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' apply plugin: 'docker' version = '1.0.0' jar { baseName = 'springdemo' } task buildDocker(type: Docker, dependsOn: build) { push = true applicationName = jar.baseName dockerfile = file('src/main/docker/Dockerfile') doFirst { copy { from jar into stageDir } } }
2. Compile the project
docker build
Three generation mirrors
docker build buildDocker
Four running containers
docker run -p 80:8080 springdemo-1.0.0
Five-year picture