Using a customized devfile to create a workspace
Devfiles are yaml text files used for development environment customization. Use them to configure a devfile to suit your specific needs and share the customized devfile across multiple workspaces to ensure identical user experience and build, run, and deploy behaviors across your team.
The devfile schema is being developed as an open specification at https://devfile.io.
The Red Hat documentation provides an overview and resource list for learning more about devfiles and their syntax.
Using customized devfiles
In addition to the default devfile, IBM Wazi for Dev Spaces allows users to use a customized devfile to create a workspace. These are two methods using your own devfile:
Provide your own devfile in the Git repository with your source code and start you workspace by just providing the https url to your Git repository.
Create a workspace in the Dev Spaces dashboard by using the "IBM Wazi for Dev Spaces" tile and then modify the devfile in the dashboard user interface.
The Red Hat documentation provides a detailed overview to creating workspaces in addition to the information provided here.
Creating a devfile
When creating a devfile for IBM Wazi for Dev Spaces, ensure that it uses the Wazi container image that provides the capabilities needed for enterprise development projects. When you create a workspace from the stack, you will get that image automatically. You can copy that devfile and make modifications for your needs. Use the following minimal template if you plan to create a devfile for your Git repository from scratch using the first method listed above.
Simple devfile for enterprise development projects using the Wazi for Dev Spaces image:
schemaVersion: 2.2.0
metadata:
name: wazi-devspaces
components:
- name: wazi
container:
image: icr.io/wazi-code/ibm-wazi-for-devspaces-sidecar:latest
memoryLimit: 3072Mi
mountSources: true
sourceMapping: /projects
volumeMounts:
- name: zowe
path: /home/user/.zowe
- name: zowe
volume:
size: 100MiAdvanced devfile that also includes Wazi Analyze:
schemaVersion: 2.2.0
metadata:
name: wazi-devspaces
components:
- container:
endpoints:
- attributes:
cookiesAuthEnabled: false
exposure: public
name: analyze-api
protocol: https
targetPort: 4680
- attributes:
cookiesAuthEnabled: false
exposure: public
name: analyze-ui
protocol: https
targetPort: 5000
- attributes:
cookiesAuthEnabled: false
exposure: none
name: analyze-weasy1
protocol: http
targetPort: 4080
- attributes:
cookiesAuthEnabled: false
exposure: none
name: analyze-weasy2
protocol: http
targetPort: 4081
- attributes:
cookiesAuthEnabled: false
exposure: none
name: analyze-swagger
protocol: http
targetPort: 8000
image: icr.io/wazi-code/ibm-wazi-for-devspaces-sidecar:latest
memoryLimit: 3072Mi
mountSources: true
sourceMapping: /projects
volumeMounts:
- name: zowe
path: /home/user/.zowe
- name: data
path: /home/user/wazianalyze/data
name: wazi
- name: zowe
volume:
size: 100Mi
- name: data
volume:
size: 1024MiNote: Using this Analyze configuration requires a license for Wazi Analyze. It will cause license usage to be counted differently, for IBM Z and Cloud Modernization Stack VPC ratio table.
Modifying a devfile
After you created a workspace using the dashboard tile "IBM Wazi for Dev Spaces", you can use the dashboard user interface to make modifications. For example, if you are working on a hybrid application and want to combine COBOL development with a stack for Nodejs and MongoDB, you can modify the first sample above in the following way to combine content from two of the Dev Spaces stacks. In this case, the usage of the ibm-wazi-for-devspaces-sidecar container is extended to also provide environment variables and endpoints for running a nodejs app, as our image also contains everything needed for nodejs development. It then also added another image called mongodb-36-rhel7 that provides a pre-configured instance of a MongoDB that can be used for development. Also, you find two more mounted storage volumes for npm and mongo in addition to the Zowe profile storage the Wazi image is using.
schemaVersion: 2.2.0
metadata:
name: wazi-devspaces
components:
- name: wazi-node
container:
image: icr.io/wazi-code/ibm-wazi-for-devspaces-sidecar:latest
memoryLimit: 3072Mi
env:
# The values below are used to set up the environment for running the application
- name: SECRET
value: 220fd770-c028-480d-8f95-f84353c7d55a
- name: NODE_ENV
value: production
endpoints:
- exposure: public
name: nodejs
targetPort: 8080
mountSources: true
sourceMapping: /projects
volumeMounts:
- name: zowe
path: /home/user/.zowe
- name: npm
path: /home/user/.npm
- name: mongo
container:
image: registry.redhat.io/rhscl/mongodb-36-rhel7:1-50
env:
- name: MONGODB_USER
value: user
- name: MONGODB_PASSWORD
value: password
- name: MONGODB_DATABASE
value: guestbook
- name: MONGODB_ADMIN_PASSWORD
value: password
endpoints:
- name: mongodb
exposure: internal
targetPort: 27017
memoryLimit: 512Mi
mountSources: false
volumeMounts:
- name: mongo-storage
path: /var/lib/mongodb/data
- name: zowe
volume:
size: 100Mi
- name: npm
volume:
size: 1G
- name: mongo-storage
volume:
size: 1G
commands:
- id: 1-run
exec:
label: "Run the application"
component: nodejs
workingDir: ${PROJECTS_ROOT}/nodejs-mongodb-sample
commandLine: "npm install && node --inspect=9229 app.js"
group:
kind: run