Prebuilt vs. non-built tasks

How do I specify tasks that should be prebuilt vs. tasks that should not in my .gitpod.yml?

image: gitpod/workspace-full
tasks:
- init: yarn install
- command: sh ./gitpod-setup.sh && npm start
name: Set up script
ports:

  • port: 8080
    onOpen: open-browser

I’d yarn install to be prebuilt but sh ./gitpod-setup.sh && npm start to be run when the user first opens gitpod.

This would do:

image: gitpod/workspace-full
tasks:
 - init: yarn install
   command: sh ./gitpod-setup.sh && npm start
   name: Set up script
ports:
 - port: 8080
   onOpen: open-browser

Explanation:
Tasks contains a list of entries (each - demotes one entry) and each entry supports three life cycle phases:
pre: gets executed first and always
init: gets executed next during prebuilds and not when starting a prebuilt workspace.
command: gets executed last and only when workspaces start (i.e. not during prebuilds)

The documentation for that can be found here: https://www.gitpod.io/docs/config-start-tasks/#defining-commands

1 Like

Thank you!