Skip to content

Instantly share code, notes, and snippets.

@ibuziuk
Last active April 24, 2026 14:50
Show Gist options
  • Select an option

  • Save ibuziuk/bc0d6ce001904ee47ed4e729bc4f2aa7 to your computer and use it in GitHub Desktop.

Select an option

Save ibuziuk/bc0d6ce001904ee47ed4e729bc4f2aa7 to your computer and use it in GitHub Desktop.

Generate Devfile Skill

Description

Generates a devfile.yaml for a project repository. Devfiles are YAML files that define development environments for cloud-native applications following the Devfile v2 specification.

When to Use

  • When a project needs a new devfile.yaml
  • When setting up a cloud-native development environment (e.g., OpenShift Dev Spaces, Eclipse Che)
  • When a user asks to create or regenerate a devfile

Instructions

Step 1: Analyze the Project

Examine the repository to determine:

  1. Project type — Look at build files to identify the stack:
    • pom.xml or build.gradle → Java (check for Quarkus, Spring Boot, etc.)
    • package.json → Node.js (check for React, Angular, Vue, etc.)
    • requirements.txt or pyproject.toml → Python
    • go.mod → Go
    • Cargo.toml → Rust
    • Gemfile → Ruby
    • Containerfile or Dockerfile → Container-based
  2. Framework — Identify specific frameworks from dependencies
  3. Build commands — Determine how the project is built and run
  4. Required ports — Identify which ports the application exposes
  5. Existing devfile — Check if a devfile.yaml already exists and whether it should be updated or replaced

Step 2: Select the Appropriate Base Image

Choose a Universal Developer Image (UDI) or stack-specific image:

Stack Recommended Image
Java (general) registry.redhat.io/devspaces/udi-rhel8
Java + Quarkus registry.redhat.io/devspaces/udi-rhel8
Java + Spring Boot registry.redhat.io/devspaces/udi-rhel8
Node.js registry.redhat.io/devspaces/udi-rhel8
Python registry.redhat.io/devspaces/udi-rhel8
Go registry.redhat.io/devspaces/udi-rhel8
.NET registry.redhat.io/devspaces/udi-rhel8
Multi-language registry.redhat.io/devspaces/udi-rhel8

If the project has a parent devfile URI, prefer using the parent field instead of inlining everything.

Step 3: Generate the Devfile

Create a devfile.yaml at the project root following this structure:

schemaVersion: 2.3.0
metadata:
  name: <project-name>
  version: <project-version>  # optional
  description: <brief-description>  # optional
  language: <primary-language>  # optional, e.g., Java, JavaScript, Python
  projectType: <framework>  # optional, e.g., Quarkus, Spring Boot, Node.js

# Use parent if a shared/base devfile exists
# parent:
#   uri: <url-to-parent-devfile>

components:
  - name: tools
    container:
      image: registry.redhat.io/devspaces/udi-rhel8
      memoryLimit: 4Gi
      memoryRequest: 512Mi
      cpuLimit: "2"
      cpuRequest: 250m
      mountSources: true
      volumeMounts:
        - name: m2
          path: /home/user/.m2  # For Java/Maven projects
      endpoints:
        - name: https-<app>
          targetPort: <port>
          exposure: public
          protocol: https

  # Add volume components as needed
  - name: m2
    volume:
      size: 2Gi

commands:
  - id: build
    exec:
      label: "Build"
      component: tools
      workingDir: ${PROJECT_SOURCE}
      commandLine: "<build-command>"
      group:
        kind: build
        isDefault: true

  - id: run
    exec:
      label: "Run"
      component: tools
      workingDir: ${PROJECT_SOURCE}
      commandLine: "<run-command>"
      group:
        kind: run
        isDefault: true

  - id: debug
    exec:
      label: "Debug"
      component: tools
      workingDir: ${PROJECT_SOURCE}
      commandLine: "<debug-command>"
      group:
        kind: debug
        isDefault: true

  - id: test
    exec:
      label: "Test"
      component: tools
      workingDir: ${PROJECT_SOURCE}
      commandLine: "<test-command>"
      group:
        kind: test
        isDefault: true

Step 4: Customize Based on Project Type

Java + Maven (Quarkus)

commands:
  - id: build
    exec:
      commandLine: ./mvnw package -DskipTests
      component: tools
      workingDir: ${PROJECT_SOURCE}
      group:
        kind: build
        isDefault: true
  - id: run
    exec:
      commandLine: ./mvnw quarkus:dev -Dquarkus.http.host=0.0.0.0
      component: tools
      workingDir: ${PROJECT_SOURCE}
      group:
        kind: run
        isDefault: true
  - id: debug
    exec:
      commandLine: ./mvnw quarkus:dev -Dquarkus.http.host=0.0.0.0 -Ddebug=5005
      component: tools
      workingDir: ${PROJECT_SOURCE}
      group:
        kind: debug
        isDefault: true
  - id: test
    exec:
      commandLine: ./mvnw test
      component: tools
      workingDir: ${PROJECT_SOURCE}
      group:
        kind: test
        isDefault: true
  • Default port: 8080
  • Volume: .m2 cache at /home/user/.m2

Java + Maven (Spring Boot)

commands:
  - id: build
    exec:
      commandLine: ./mvnw package -DskipTests
  - id: run
    exec:
      commandLine: ./mvnw spring-boot:run -Dspring-boot.run.arguments="--server.address=0.0.0.0"
  - id: test
    exec:
      commandLine: ./mvnw test
  • Default port: 8080

Java + Gradle

commands:
  - id: build
    exec:
      commandLine: ./gradlew build -x test
  - id: run
    exec:
      commandLine: ./gradlew bootRun  # Spring Boot

Node.js

commands:
  - id: install
    exec:
      commandLine: npm install
      group:
        kind: build
        isDefault: false
  - id: build
    exec:
      commandLine: npm run build
      group:
        kind: build
        isDefault: true
  - id: run
    exec:
      commandLine: npm start
      group:
        kind: run
        isDefault: true
  - id: test
    exec:
      commandLine: npm test
      group:
        kind: test
        isDefault: true
  • Default port: 3000 (React/Express) or 4200 (Angular) or 5173 (Vite)
  • Volume: npm cache

Python

commands:
  - id: install
    exec:
      commandLine: pip install -r requirements.txt
      group:
        kind: build
        isDefault: true
  - id: run
    exec:
      commandLine: python app.py
      group:
        kind: run
        isDefault: true
  - id: test
    exec:
      commandLine: pytest
      group:
        kind: test
        isDefault: true
  • Default port: 8000 (Django/FastAPI) or 5000 (Flask)

Go

commands:
  - id: build
    exec:
      commandLine: go build -o app .
      group:
        kind: build
        isDefault: true
  - id: run
    exec:
      commandLine: go run .
      group:
        kind: run
        isDefault: true
  - id: test
    exec:
      commandLine: go test ./...
      group:
        kind: test
        isDefault: true

Step 5: Validate

After generating the devfile:

  1. Ensure the YAML is valid (proper indentation, no syntax errors)
  2. Verify the schemaVersion is 2.3.0
  3. Confirm all referenced components in commands exist in the components section
  4. Check that port numbers match the application's actual configuration
  5. Verify volume mount paths are correct for the stack

Step 6: Handle Parent Devfiles

If the project uses a parent devfile (common in enterprise environments):

schemaVersion: 2.3.0
metadata:
  name: <project-name>
parent:
  uri: <url-to-parent-devfile>
  # OR reference a devfile registry
  # id: <devfile-id>
  # registryUrl: <registry-url>
  • Parent devfiles provide base components and commands
  • Child devfiles can override or extend parent definitions
  • Only include fields that differ from or extend the parent

Output

The skill produces a devfile.yaml file at the project root that is ready to use with OpenShift Dev Spaces, Eclipse Che, or any devfile-compatible tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment