Category Archives: JavaEE

Continuous Deployment: Java EE with Kubernetes on Google Cloud

In December of 2017 I was working on a Java EE web project from my startup.
One of the first things that needed to be defined was where to host the application.
After studying Heroku, Openshift, AWS and Google Cloud, I decided to use Docker containers on Google Cloud infrastructure.

Google Cloud with Docker container lets you use all the power of the Java EE stack. It has low prices, ease of configuration, scalability and platform independence.

As it was a private project, I chose to use Bitbucket because it has Git and pepilines to do the integrations with Google Cloud and Slack.

The following are the settings required to run the continuous integration and continuous deployment pipelines:

At the root of the Java project two files are required:



You must add three Environment variables:

Go to your repository settings in Bitbucket and navigate to Pipelines > Environment variables. Create a new variable named GCLOUD_API_KEYFILE and paste the encoded service account credentials in it.

Add a new variable called GCLOUD_PROJECT and set the value to the key of your Google Cloud project.

Add another variable called APP_NAME and set the name of your app.

In Pipelines you can configure the build schedule.

See also:

Deploying a containerized Java web application

Install Docker CE

1) Set up the docker repository:

sudo apt-get update

sudo apt-get install apt-transport-https ca-certificates curl software-properties-common

curl -fsSL | sudo apt-key add -

sudo add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"

2) Install Docker CE

sudo apt-get update

sudo apt-get install docker-ce

3) Verify the installation

$ sudo docker run hello-world

Deployment with the jboss/wildfly Docker image

AdminFaces is an open source project which brings Bootstrap and AdminLTE to your application via a PrimeFaces theme and a JSF responsive template.

The sample files can be downloaded here

1) Create docker file Dockerfile with following content:

 FROM jboss/wildfly
 ADD admin-starter.war /opt/jboss/wildfly/standalone/deployments/


2) Place your admin-starter.war file in the same directory as your Dockerfile.

3) Run the build with:

sudo docker build --tag=admin-starter-app .

4) Run the container with:

sudo docker run -it -p 8080:8080 admin-starter-app

Application will be deployed on the container boot.

The application is available at http://localhost:8080/admin-starter

Pushing and Pulling to and from Docker Hub

1) Log into the Docker Hub from the command line

sudo docker login

2) Tag your image

sudo docker tag admin-starter-app yourhubusername/admin-starter-app:v0.0.1

3) Push your image to the repository you created

sudo docker push yourhubusername/admin-starter-app:v0.0.1

4) Create your Docker droplet

5) Login in Digital Ocean

ssh user@yourDigitalOceanMachine

6) Allow Connections

sudo ufw allow 8080

7)  Pull your image

sudo docker pull yourhubusername/admin-starter-app:v0.0.1

8) Run the container with

sudo docker run -it -p 8080:8080 yourhubusername/admin-starter-app:v0.0.1

Application will be deployed on the container boot.

The application is available at http://yourDigitalOceanMachine:8080/admin-starter