Spring MVC JDBC Template

Create Docker image for Java

Using this repository, we’ll help you get up to speed with basic functionality such as: compiling, testing and building Docker images.

This project uses JAVA, SpringMVC, Tomcat, MySQL, Maven to build an application which will eventually become a distributable Docker image.

Looking around

In the root of this repository you’ll find a file named codefresh.yml, this is our build descriptor and it describes the different steps that comprise our process. Let’s quickly review the contents of this file:

codefresh.yml

version: '1.0'
stages:
  - prepare
  - test
  - package
steps:
    main_clone:
      title: 'Cloning main repository...'
      type: git-clone
      repo: codefreshdemo/cf-example-java-hello-world
      revision: 'master'
      git: github-1
      stage: prepare
    unit_test:
      title: Unit Tests
      image: maven:latest
      stage: test
      commands:
        - mvn -version
    build_image:
      title: Building Image
      type: build
      stage: package
      dockerfile: Dockerfile
      tag: master
      image_name: java-spring-mvc-jdbc
Example

Just head over to the example repository in Github or this repository in Bitbucket and follow the instructions there.

Gradle version

You can also see how to build this example with Gradle. Just go to the branch gradle of this repository and open the Dockerfile.gradle in this repository. To see how it works in Codefresh - add this repository to your account specifying the branch gradle and codefresh.yml as build method.

Expected result

Here is the pipeline in action:

Spring MVC pipeline

Spring MVC pipeline