Docker Community Forums

Share and learn in the Docker community.

Separate Docker Files for Build and Application - How to build on Docker Hub?

dockerhub

(Rohitghatol) #1

I have a Spring Boot (Java) Project. I have 2 Docker Files

  1. Build Docker File - which installs Java SDK, Maven/Gradle and Downloads Dependency and finally builds the Single Jar file I need. This Jar file is my Application. This Jar File is then copied back to local directory using Volume (Docker)
  2. Application Docker File - which install bare bone, that is Java JRE, SSL Certificate and the Application Jar File (which was built by Build Docker File)

What I want to do is

  1. When some one checks in to the master branch of by github repository
    1. Fire my Build Docker File and create My Application Jar.
    2. Fire my Application Docker File and create the Application Docker Container Image. This Container Image I want to upload on Docker Hub

How do I do this on Docker Hub?


(Chandra S) #2

Hi Rohit,

I am planing to use the same kind of setup for my java applications. Could you please share those two files to me to kick start my project? and coming to your Question, i think can use Jenkins for the CI/CD?

Thanks,
CK


(Raj Chaudhuri) #3

You should use a multi-stage Docker file. Details here: