Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of docker multi stage builds #1057

Merged
merged 6 commits into from
Apr 6, 2019

Conversation

KeZiio
Copy link
Contributor

@KeZiio KeZiio commented Jul 23, 2018

This PR adds support of docker multi stage builds using Dockerfile.
See https://docs.docker.com/develop/develop-images/multistage-build/ for feature description.

@codecov
Copy link

codecov bot commented Jul 23, 2018

Codecov Report

Merging #1057 into master will increase coverage by 0.29%.
The diff coverage is 52.94%.

@@             Coverage Diff              @@
##             master    #1057      +/-   ##
============================================
+ Coverage     51.98%   52.27%   +0.29%     
+ Complexity     1486     1405      -81     
============================================
  Files           150      147       -3     
  Lines          7951     7566     -385     
  Branches       1192     1149      -43     
============================================
- Hits           4133     3955     -178     
+ Misses         3412     3233     -179     
+ Partials        406      378      -28
Impacted Files Coverage Δ Complexity Δ
.../io/fabric8/maven/docker/service/BuildService.java 63.15% <40%> (+34.48%) 18 <0> (+9) ⬆️
...a/io/fabric8/maven/docker/util/DockerFileUtil.java 79.54% <71.42%> (+9.7%) 13 <1> (-4) ⬇️
...abric8/maven/docker/service/ServiceHubFactory.java 0% <0%> (-80%) 0% <0%> (-2%)
...va/io/fabric8/maven/docker/service/ServiceHub.java 0% <0%> (-36.59%) 0% <0%> (-3%)
...java/io/fabric8/maven/docker/VolumeCreateMojo.java 0% <0%> (-30%) 0% <0%> (-2%)
...java/io/fabric8/maven/docker/VolumeRemoveMojo.java 0% <0%> (-30%) 0% <0%> (-2%)
...o/fabric8/maven/docker/service/ArchiveService.java 0% <0%> (-26.67%) 0% <0%> (-1%)
...a/io/fabric8/maven/docker/service/WaitService.java 0% <0%> (-4.24%) 0% <0%> (-1%)
...va/io/fabric8/maven/docker/service/RunService.java 47.96% <0%> (-4.16%) 22% <0%> (-3%)
.../io/fabric8/maven/docker/service/WatchService.java 0% <0%> (-3.8%) 0% <0%> (-1%)
... and 48 more

@KeZiio KeZiio force-pushed the docker_multi_stage_builds branch from dc4c1a9 to 00e11fa Compare July 23, 2018 14:28
*/
@Deprecated
public static String extractBaseImage(File dockerFile, FixedStringSearchInterpolator interpolator) throws IOException {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

INFO Do not forget to remove this deprecated code someday. rule

@ghost
Copy link

ghost commented Jul 23, 2018

SonarQube analysis reported 1 issue

  • INFO 1 info

Watch the comments in this conversation to review them.

@rhuss
Copy link
Collaborator

rhuss commented Jul 23, 2018

Thanks a lot ! The PR looks good, but could you please elaborate a bit why mutlti stage builds would make sense in the context of d-m-p ? Do you have concrete use case ?

@KeZiio
Copy link
Contributor Author

KeZiio commented Jul 24, 2018

Hi, @rhuss

Do you have concrete use case ?

I faced it when started mysql container for integration test with fixtures. So Dockerfile looks like next:

ARG FIXTURE_VERSION
FROM mysql-fixture-base:5.6-${FIXTURE_VERSION}
# This images uses ONBUILD instructions that are run at this point
# This delayed execution is necessary to configure database 
# (i.e. user/pass and schema) and ADD fixture files from the child image.

# Start from a clean MySQL image
FROM mysql:5.6
#
# Some Copy instruction to keep only DB related files

In turn mysql-fixture-base:5.6 is created in separate pipeline using Dockerfile like:

# standalone application that patches db
FROM patcher

FROM mysql:5.6

# Some COPY and RUN instruction to patch DB

But when i run my test i want to get rid of intermediate fixture files and patcher application so that image become more lightweight.

@rohanKanojia rohanKanojia requested a review from rhuss March 2, 2019 10:27
Copy link
Collaborator

@rhuss rhuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with the change, let's merge it.

@rhuss rhuss merged commit 038f0df into fabric8io:master Apr 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants