Skip to content

redhat-developer-demos/quarkus-java-builder

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quarkus Java Builder

Docker Repository on Quay

The container builder image that can be used to build QuarkusIO applications.

The image is baked in with the following tools:

Using the image

Docker pull docker pull quay.io/rhdevelopers/quarkus-java-builder

Configuration

Table 1. Environment Variables
Environment Variable Use Default

WORK_DIR

The directory that contains sources to build

/project

MVN_CMD_ARGS

The maven goals that need to run

mvn package -Pnative

DESTINATION_NAME

The fully qualified container image name, where the built image will be pushed e.g. docker.io/myrepo/myapp

MAVEN_MIRROR_URL

The maven mirror url, typically the repository manager URL to make builders faster

HTTP_PROXY_HOST

The HTTP proxy host to use with Maven

HTTP_PROXY_PORT

The HTTP proxy port to use with Maven

HTTP_PROXY_USERNAME

The HTTP proxy port to use with Maven

HTTP_PROXY_PASSWORD

The HTTP proxy password to use with Maven

HTTP_PROXY_NONPROXYHOSTS

The HTTP hosts to which proxy does not apply

The builder image has a default maven-run.sh script that runs a maven build to package the QuarkusIO application. .

Example Application

You can download the sample source code from knative-tutorial-greeter

git clone https://github.com/redhat-developer-demos/knative-tutorial-greeter

Lets call the cloned folder as $PROJECT_HOME

Minikube

Minikube is single node Kubernetes cluster that can be used for development purposes. You can download and install Minikube to test the builder.

As of now we dont have a standard way to build and deploy Kubernetes applications from sources. For the sake of demoing this builder we will will use Knative Build, the following command will start minikube locally and setup Knative build in it.

Vanilla Kubernetes Deployment using Knative Build

$PROJECT_HOME/example/minikube-start.sh

Deploy Quarkus application

cd $PROJECT_HOME/java/quarkus

Before the knative resources are deployed, we need to run the following maven command to configure the build to ones need:

# This will generate the needed knative resources in target/knative directory

mvn -Dcontainer.registry.url='https://index.docker.io' \#(1)
    -Dcontainer.registry.user='demo' \#(2)
    -Dcontainer.registry.password='password!' \#(3)
    -Dgit.source.revision='master' \#(4)
    -Dgit.source.repo.url='https://github.com/kameshsampath/knative-tutorial-greeter.git' \#(5)
    -Dapp.container.image='docker.io/demo/quarkus-greeter' \#(6)
    -Dapp.context.dir='java/quarkus' \#(7)
    clean package
  1. The docker hub registry url

  2. The docker hub user name

  3. The docker hub user password

  4. The Git source revision

  5. The Git source repository url, this repo already has a quarkus app

  6. The application container image name, maps to DESTINATION_NAME in Environment Variables

  7. The context directory within the sources that will be built

# apply the resources
kubectl apply -f target/k8s #(1)
  1. This will create the following kubernetes resources:

    • A Kubernetes Service Account called build-bot that holds container registry push secrets and get events from Knative Builds

    • build-watcher role and role binding

    • A maven pvc that can cache maven artifacts after first build, for subsequent faster builds

    • A Deployment and a Service that uses the built image

Note
  • Build and deploy will take time at least for the first build as it warms the .m2 cache and downloads the base images

Watch the status of the application using and use CTRL + C when you want to terminate the watch.

kubectl get pods -w

Once the build is successfully completed you should see the deployment quarkus-greeter coming up in few mins, once you see the quarkus-greeter application running you can call it via curl -v $(minikube service quarkus-greeter --url)