Devfile.yaml for remote dev environment laravel keeps failing

Hey there! To run a laravel app I am trying to get a Dev Environment going. Im not really awesome at containers and docker so Ive been puzzling with this an entire day.  I am using the standard Laravel devfile at https://registry.devfile.io/viewer/devfiles/community/php-laravel?devfile-version=2.0.0 and Ive added the attributes that the documentation needs like Username, space.instanceType etc…

I have the devfile.yaml below (I have changed the username and as password I use my Personal Permanent Token (?). 

It accepts it as a valid file and starts booting up, but then it errors out with this message: Failed to start: A critical dev environment process exited with error code 1. What to do, and does anyone have a working devfile.yaml I could work with because this is driving me bonkers :D Thanks  

schemaVersion: 2.2.0
metadata:
  name: php-laravel
  displayName: Laravel
  description: "Laravel is an open-source PHP framework, which is robust and easy to understand.
    It follows a model-view-controller design pattern.
    Laravel reuses the existing components of different frameworks which helps in creating a web application.
    The web application thus designed is more structured and pragmatic."
  icon: https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/laravel.svg
  tags:
    - PHP
    - Composer
    - Laravel
  projectType: Laravel
  language: PHP
  provider: Red Hat
  version: 2.0.0
starterProjects:
  - name: php-laravel-starter
    git:
      checkoutFrom:
        revision: main
      remotes:
        origin: https://github.com/devfile-samples/devfile-stack-php-laravel.git
attributes:
  space:
    # regular, large, xlarge
    instanceType: regular
    # a default IDE for the project
    editor:
      # (Required) IDE type: Idea, WebStorm, PyCharm,
      # RubyMine, CLion, Fleet, GoLand, PhpStorm
      type: PhpStorm
      version: '2023.3'
      # Space uses JetBrains Toolbox App to install IDEs to a dev environment.
      # updateChannel defines IDE version release stage: Release, EAP
      updateChannel: EAP
      # JVM configuration (appends to the default .vmoptions file)
      vmoptions:
        - '-Xms2048m'
        - '-Xmx4096m'
    requiredParameters:
      # (Required) the name of the environment variable
      # that will be available in the dev environment
      - name: USERNAME
        description: 'MY USERNAME'
    requiredSecrets:
      - name: PASSWORD
        description: 'MYPERSONALPERMANENTTOKEN'
components:
  - container:
      endpoints:
        - name: http-laravel
          targetPort: 8000
      image: quay.io/devfile/composer:2.5.8
      args: ["tail", "-f", "/dev/null"]
      memoryLimit: 1024Mi
      mountSources: true
    name: runtime
commands:
  - exec:
      commandLine: composer install
      component: runtime
      group:
        isDefault: false
        kind: build
      workingDir: ${PROJECT_SOURCE}
    id: install
  - exec:
      commandLine: cp .env.example .env
      component: runtime
      group:
        isDefault: false
        kind: build
      workingDir: ${PROJECT_SOURCE}
    id: cp-env
  - exec:
      commandLine: php artisan config:clear
      component: runtime
      group:
        isDefault: false
        kind: build
      workingDir: ${PROJECT_SOURCE}
    id: clear-config
  - exec:
      commandLine: php artisan key:generate
      component: runtime
      group:
        isDefault: false
        kind: build
      workingDir: ${PROJECT_SOURCE}
    id: gen-new-app-key
  - exec:
      commandLine: composer dump-autoload
      component: runtime
      group:
        isDefault: false
        kind: build
      workingDir: ${PROJECT_SOURCE}
    id: composer-dump
  - composite:
      commands:
        - install
        - cp-env
        - clear-config
        - gen-new-app-key
        - composer-dump
      group:
        isDefault: true
        kind: build
      label: Provision Laravel Server
      parallel: false
    id: init-server
  - exec:
      commandLine: php artisan serve --host=0.0.0.0
      component: runtime
      group:
        isDefault: true
        kind: run
      workingDir: ${PROJECT_SOURCE}
    id: run
0
1 comment

Hi! 
From what I understand, we cannot use any devfile.yaml, even if it is version 2.2.0. 
At this point, Space does not support several attributes, such as "commands", some within the metadata, etc. 
I took the Dockerfile from the Space documentation and made some updates to be able to build it. (https://www.jetbrains.com/help/space/run-environment-in-dev-environment.html#default-docker-image)


You can use the Dockerfile directly in devenv.yaml, but in my tests, it takes 6 minutes to build every time I open the IDE. 
If you create an image with the Dockerfile, publish it in your project's Packages, and use this image in the devfile.yaml, it takes 1:30, as you don't need to build it every time. (https://www.jetbrains.com/help/space/publish-images.html#publish-images-using-docker-command-line-tool

I used warm-up on both devfiles, but I didn't see any time improvement; I must be doing something wrong. 

You can use the default Space image, which is much faster to launch (30 seconds). 
But you will have to install/update packages every time you start the IDE. 

I'm currently using my custom image.

To start Laravel, I used sail: 

composer install

npm install

./vendor/bin/sail up 

And I redirected ports to access port 80 of the Dev Environment, through a random port generated by the IDE.

0

Please sign in to leave a comment.