Creating and using custom images

Overview

The developer images provided with OpenShift Dev Spaces are examples that comprise typical stacks of development tools covering common development scenarios. However, no development organization or project is the same and there is always a need to add, swap out, or remove tools for different teams and project. The idea is the teams can take the images provides as base images and modify them or even copy the dockerfiles used to build them and adjust them.

The core developer image provided by Red Hat is called Red Hat OpenShift Dev Spaces - Universal Developer Image (UDI)open in new window. It was designed with common purpose in mind containing many programming languages and development technologies. It can be used as is, can be combined with other images running as sidecar container in parallel, or used as a base image for customization.

There also other images available either provided by Red Hat or the Eclipse Che community that are built for special purposes. One example is the Ansible Development Toolsopen in new window image providing support for developing Ansible playbooks. This image is used by the Ansible stack available in the OpenShift Dev Spaces dashboard.

IBM also provides a sample image based on the UDI that adds content for z/OS development such as Zowe CLI, IBM's plugins for Zowe CLI, its Red Hat Ansible Certified Content for IBM Z and other. The dockerfile for this image is available at https://github.com/IBM/wazi-devspaces-imagesopen in new window so that you can see all the modification applied. You can use it and modify it further. This same Git repository also contains an examples for a sidecar that can in parallel to the UDI that only provides Zowe CLI and IBM's plugins. It could be combined with the UDI and the Ansible image mentioned above.

Building the sample images

To build the example images of the https://github.com/IBM/wazi-devspaces-imagesopen in new window repository you require an account with Red Hat that entitles you to pull base images from their registry, which you should have received with your purchase of OpenShift. Perform the following steps:

  • Create a development environment that has Docker or Podman installed and configured.

  • Clone the Git repository.

  • Log on to your Red Hat account using

    docker login registry.redhat.io
    
  • To build the full image that is based on the UDI execute

    docker build -f devspaces-sidecar/wazi.Dockerfile -t your-registry.com/your-namespace/idzee-devspaces-sidecar:5.1.0 ./devspaces-sidecar
    
  • To build the minimal image that you can use in parallel to the UDI execute

    docker build -f devspaces-sidecar-minimal/wazi.Dockerfile -t your-registry.com/your-namespace/idzee-devspaces-sidecar:5.1.0 ./devspaces-sidecar-minimal
    

Once you are able to build these sample you can start modifying them adding the tools that you need in addition to what they already provide.

Deploying the sample images

Once you have your image built you can deploy it to your personal image registry. Follow the instructions of your provide. For example, if you are using OpenShift in an IBM Cloud VPC then you can follow these base steps:

Configuring OpenShift Dev Spaces to use your personal registry

Dev Spaces users can configure a personal container registry directly from the Dev Spaces dashboard.

  1. Log on to the Dev Spaces Dashboard.
  2. In the tool bar select your user name menu and choose "User Preferences".
  3. The first tab of the User Preferences page is label "Container Registries".
  4. Click the "Add Container Registry" button and fill in the form.
  5. For IBM Cloud registries you provide the name of your registry, "iamapikey" for the Username value, and a valid IAM api key associated with your registry account as the password.

Creating a devfile with your personal image

To create a Dev Spaces workspace with your personal image, create a devfile in your Git repository that lists your image. For example,

schemaVersion: 2.3.0
metadata:
  name: idzee-devspaces

components:
  - name: zowe
    volume:
      size: 100Mi
  - name: wazi-terminal
    container:
      image: your-registry.com/your-namespace/idzee-devspaces-sidecar@sha256:your-sha
      memoryLimit: 3072Mi
      mountSources: true
      volumeMounts:
        - name: zowe
          path: /home/user/.zowe

Then you can create a workspace by providing the URL to your Git repository in the Dashboard's "Import from Git" text field.

Last Updated:
Contributors: PETER HAUMER