p2018
p2018

Reputation: 125

Docker Image which uses another image for running test cases

I have a BDD framework in Java which I am planning to dockerize. I am able to build and run that image as a whole. But what I want is:

To build 2 images, Image-1: Entire project (without feature files) & Image-2: Feature files.

Reason to do this is: My feature file will change often. I don't want to create my image again every time to install JDK and maven when there is only a change in the feature file.

What I expect is - Image-1 runs always as a container in background and when there is a change in feature files, I build Image-2 and start it as a container. This should trigger test by using already running container which has an entire dependency.

Upvotes: 1

Views: 360

Answers (1)

atline
atline

Reputation: 31644

Reason to do this is: My feature file will change often. I don't want to create my image again every time to install JDK and maven when there is only a change in the feature file.

If you just want to meet above requirement, what you is just image inherit like next:

base/Dockerfile:

FROM ubuntu:16.04

# install JDK/MAVEN here
RUN xxx

Build a base image now:

$ docker build -t mybase:1 .

Then, for your application, use this base image:

app/Dockerfile:

FROM mybase:1

# add new feature files here
ADD ... ...

Everytime, your feature file change, you could rebuild your app Dockerfile and run a container base on this new built out image. But, As the JDK/MAVEN is in another base image (mybase:1) which was already built there, so they won't be built again.

Upvotes: 1

Related Questions