I found two solutions for this.
1. Increase build pod resources.
resources: requests: cpu: "100m" memory: "1024Mi"
2. Build locally using docker build and push the image to the image stream.
- Build locally
docker build -t myapi - Tag build
docker tag myapi default-route-openshift-image-registry.apps.ca-central-1.starter.openshift-online.com/apis/myapi- Login to an openshift registry
docker login default-route-openshift-image-registry.apps.ca-central-1.starter.openshift-online.com -u $(oc whoami) -p $(oc whoami -t)- Push the image to the registry
docker push default-route-openshift-image-registry.apps.ca-central-1.starter.openshift-online.com/apis/myapi