Categories
development

Building Apache Ofbiz Docker Images

Apache Ofbiz (https://ofbiz.apache.org/) is an open source suite of business applications that companies can use to manage customer relationships, order processing, warehouse management, HR and lots of other functions.

This post covers how to build Ofbiz as a docker image so it can be deployed as a docker container for testing.

Pre-requisites

To retrieve, build and run Ofbiz docker images you will need the following installed on your system:

  • Docker
  • Git
  • Java
  • JAVA_HOME environment set.

If running on Windows I would suggest installing the following:

  • Git for windows. This will give you the git-bash terminal.

Get the Sources

We have a few sets of sources to download:

  • The docker-ofbiz project
  • Ofbiz-framework
  • Any ofbiz plugins (optional)

At a shell prompt retrieve the docker-ofbiz sources using:

git clone https://github.com/danwatford/ofbiz-docker

Change to the new ofbiz-docker directory and then retrieve the ofbiz sources:

cd ofbiz-docker

git clone https://github.com/apache/ofbiz-framework --branch trunk

Optional Step

Next retrieve any plugin sources you want to include in the build. These must be downloaded to the ofbiz-framework/plugins directory using commands similar to:

mkdir ofbiz-framework/plugins

git clone https://github.com/danwatford/ofbizGridTest ofbiz-framework/plugins/gridTest

Build the Docker Image

Execute the gradle build to create the docker image.

At a unix of unix-like prompt (e.g. git-bash) run:

./gradlew buildOfbizImage

If at a windows command-prompt run:

gradlew buildOfbizImage

The gradle build will generate a Dockerfile and then execute the docker build. Once complete we can see the new image listed by running:

docker images

On my host I get

$ docker images
REPOSITORY  TAG      IMAGE ID        CREATED         SIZE
ofbiz       latest   42eb0f47adae    48 minutes ago  1.14GB

Run the Docker Container

To create and run a new docker container from the built image execute:

docker-compose up

The above will run the ofbiz container, loading data from the local-config directory. This allows setting of environment-specific administrator passwords.

Once the image is running visit https://localhost:8443/partymgr in your web browser and login with username admin and password ofbiz.

Depending on your docker setup, you may need to substitute localhost for your docker-machine’s IP address. You may also need to accept the browser’s warning that the connection is not secure.

Stop the Docker Container

At the terminal where docker-compose was launched press Ctrl-C to interrupt and stop the running container.

Alternatively you can open another shell, change to the docker-ofbiz directory and execute:

docker-compose down

Sources

The sources for docker-ofbiz can be found at https://github.com/danwatford/ofbiz-docker.