docker build with a template Dockerfile

I am using travis to build artefacts (jars and zips) and store them on bintray. I want to build docker images that install these artefacts for example for the ‘app’ artefact at version 0.1.0, hash abc123:

FROM some-registry/oracle-jre7
RUN wget https://BINTRAY_USER:BINTRAY_API_KEY@dl.bintray.com/USER/REPO/app-0.1.0_abc123.jar -O /opt/app.jar
EXPOSE 9000
CMD ["java", "-jar", "/opt/app.jar"]

Every time I want to create this docker image the hash (and maybe the version) will be different and I don’t want to use ‘latest’. I can easily generate the Dockerfile using a template in travis, but I’m not sure how to build the docker image. It seems I can’t build it on travis and quay.io and docker hub don’t have an api that I can post a Dockerfile or archive to (although you can do this through the ui on quay.io).

  • Jenkins triggers jobs without git changes
  • Licensing in Docker containers
  • Why does the thrift docker image need go
  • tar: Cannot read: Is a directory in docker
  • Upgrade from Docker 1.08 to 1.10
  • docker: “build” requires 1 argument. See 'docker build --help'
  • I don’t want to get travis to commit the Dockerfile to a secondary git repo because that’s getting really complex to sync the two repos if they have multiple branches. I could also commit a Dockerfile like this to the main repo and then trigger quay.io or dockerhub to build after the artefact was created (if they could somehow evaluate the git hash):

    FROM some-registry/oracle-jre7
    ENV APP_VERSION 0.1.0
    ENV APP_GIT_HASH $(git rev-parse --short HEAD) # this definitely doesn't work
    RUN wget https://BINTRAY_USER:BINTRAY_API_KEY@dl.bintray.com/USER/REPO/app-${APP_VERSION}_${GIT_HASH}.jar -O /opt/app.jar
    EXPOSE 9000
    CMD ["java", "-jar", "/opt/app.jar"]
    

    I am currently experimenting with putting a docker host in ec2 and getting travis to get it to build the docker image and push it to a docker repository on bintary, but I’d rather not have to manage the host myself.

  • Application Isolation with Linux Containers?
  • Second and Third Distributed Kafka Connector workers failing to work correctly
  • Specify container deployment target with Kubernetes, e.g. Test/Production
  • Using values of command line arguments in a file other than entrypoint.sh
  • CircleCI - Git could not resolve host when cloning repository
  • docker client (docker 1.12/centos) http: server gave HTTP response to HTTPS client
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.