0

I have a Java application in VSTS for which a build definition has been created to generate a number of build artifacts which include an ear file and a server configuration file. All of these build artifacts are zipped up in a final build definition task.

We now wish to create a Docker file which encapsulates the above build artifacts in another VSTS Docker build task. This will be done via a build definition commandline task and it is worth pointing out that our target docker registry is a corporate registry, not Azure.

The challenge I am now facing is how to generate the required docker image from the zipped artifact (or its contents if possible). Any ideas on how this could be achieved?

hitman126
  • 699
  • 1
  • 12
  • 43

1 Answers1

0

To generate a docker image from zip/tar file you can use docker load command:

docker load < test.tar.gz

Loaded image: test:latest
$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
test                latest              769b9341d937        7 weeks ago         2.489 MB

After that you can push the image to your private registry:

    docker login <REGISTRY_HOST>:<REGISTRY_PORT>
    docker tag <IMAGE_ID> <REGISTRY_HOST>:<REGISTRY_PORT>/<APPNAME>:<APPVERSION>
    docker push <REGISTRY_HOST>:<REGISTRY_PORT>/<APPNAME>:<APPVERSION>

Example :

    docker login repo.company.com:3456
    docker tag 769b9341d937 repo.company.com:3456/test:0.1
    docker push repo.company.com:3456/test:0.1

So at the end of your build pipeline add a Command Line task and run the above commands (change the values to your zip file location, username, password, registry url etc.).

Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114
  • Thanks very much for the prompt feedback @Shayki Abramczyk. Unfortunately though, I appear to have run into a brick wall as the docker load command fails in my build pipeline Task. - In the first instance, I tried the command as follows: docker load *.jar.zip and got the error message "docker load accepts no arguments". - In the second instance, I tried the command as follows: docker load -i *.jar.zip and received the error message: "Error processing tar file.....invalid tar header" – hitman126 Sep 17 '18 at 15:49