Create and use custom images

Overview

The developer images provided with OpenShift Dev Spaces are examples that comprise typical stacks of development tools which cover 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 that the teams can take the images, provide it as base images and modify 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 is designed with a common purpose in mind and includes wide range of programming languages and development technologies. It can be used as is, run alongside other images as a sidecar container, or used as a base image for customization.

There are 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 that provides 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 and IBM's plugins for Zowe CLI and others. The dockerfile for this image is available in https://github.com/IBM/wazi-devspaces-imagesopen in new window, so you can view all the applied modifications. You can use this image and modify it further. This same Git repository also includes other sample dockerfiles that show how to build a Dev Spaces image from scratch without using the UDI image as base or how to directly install additional tools like Ansible on the image instead of running a second container.

Build the sample images

To build the sample 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-udibase-rhel9/wazi.Dockerfile -t idzee-devspaces-sidecar:5.3.0 ./devspaces-sidecar-udibase-rhel9
    
  • Modify the command to build any of the other provided images. The README file in the repository also contains additional and up-to-date information.

After you are able to build these samples, start to modify them by adding the tools you need in addition to what they already provide.

Deploy the sample images

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

Configure 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, 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.

Create 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, Esther M