Getting Started

You can create a Chefile and place it into the root of your repository. The Chefile contains the configuration that will be used to setup the Che server and Che workspace.

# Usage
docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock
                    -v <path>:/data
                    -v <path-to-project>:/chedir
                     eclipse/che:<version> dir <command>

# Commands:
- init : Initialize the :/chedir volume mount and add a default Chefile file if there is none
- up : Boot Eclipse Che with workspace on folder
- down : Stop Eclipse Che and any workspaces
- ssh : Connect to the running workspace by using ssh
- status : Display if an instance of Eclipse Che is running or not for the specified folder

Chefile syntax

# This file can be generated by using `dir init` command
# Defines public IP for Che (ip should be IP of docker host)
che.server.ip = localhost

# Defines port on which your private Che server will listen.
che.server.port = 8080

# Configure how Che boots with environment variables.
# Chefile supports the full Che configuration list of che.env
che.server.properties['CHE_VERSION']='nightly'
che.server.properties['CHE_PROPERTY_http__proxy']='http://localhost:1234'

# Defines name of the workspace
workspace.name = “happy”

# Define the Docker image to use to power the workspace's runtime
# This must conform to recipe requirements
workspace.runtime.docker.image="eclipse/alpine_jdk8"

# You can - instead - define the runtime using a Dockerfile in a git repo
workspace.runtime.docker.location= "http://gist...../my-dockerfile"

# Or you could define the runtime using inline Dockerfile content
workspace.runtime.docker.dockerfile=`
FROM ...
RUN ...
ENV ...
`

# Or, you can define a multi-contianer runtime using compose
workspace.runtime.docker.composefile=`
version: 2
`

# Defines memory allocated to the workspace's runtime
workspace.ram = 2048

# Commands are processes that users execute in the IDE.
# Commands will appear in the drop down on the tool bar.
workspace.commands[0].name = "my-first-command"
workspace.commands[0].type = "mvn"
workspace.commands[0].commandLine = "mvn clean install -f ${current.project.path}"
workspace.commands[0].attributes.previewUrl = "http://${server.port.80}/${current.project.relpath}"

# If you omit the command type, it will default to a custom command (bash).
workspace.commands[1].name = "my-second-command"
workspace.commands[1].commandLine = "echo hello world"

# A command that will be executed after the workspace is loaded.
# Reference the name of a command defined above.
workspace.postload.actions[0].name="my-second-command"

# Or, by defining inline bash script within the post action.
workspace.postload.actions[1].script=`echo 'this is a post-loading command' \
                                           && while true; do \
                                           echo $(date); sleep 1; \
                                           done`

# A project has type, name, and mapped to a source repository.
# This project is mapped to the directory where Chefile is saved.
workspace.projects[0].type="blank"

# You can have multiple projects sourced from git or subversion repos
workspace.projects[1].name = "florent"
workspace.projects[1].source.type = "git"
workspace.projects[1].source.location = "https://github.com/che-samples/web-java-spring-petclinic"
workspace.projects[1].type = "maven"

Sample Chefile

We maintain a Chefile in the root of the Eclipse Che repository. It is used to build and run Che using Eclipse Che!


# Runtime image to use for booting and compiling Eclipse Che
# workspace.runtime.docker.image="florentbenoit/che-in-che"

# Commands to display in the IDE
workspace.commands[0].name="build"
workspace.commands[0].commandLine="mvn clean install -f /projects/che/assembly/assembly-main"


workspace.commands[1].name="run"
workspace.commands[1].commandLine='export CHE_VERSION="nightly" && export CHE_BIN_PATH=$(ls -d /projects/che/assembly/assembly-main/target/eclipse-che-*/eclipse-che-*); sudo docker run --rm -t -v /var/run/docker.sock:/var/run/docker.sock'
workspace.commands[1].commandLine=workspace.commands[1].commandLine+"  --env CHE_LOCAL_BINARY=${CHE_BIN_PATH/'/projects/che'/$(sudo docker inspect --format '{{ range .Mounts }}{{ if eq .Destination \"/projects/che\" }}{{ .Source }}{{ end }}{{ end }}' $(hostname))}"
workspace.commands[1].commandLine=workspace.commands[1].commandLine+'  --env CHE_PORT=54321 --env CHE_SERVER_CONTAINER_NAME="che-in-che-server" eclipse/che-launcher:nightly start'
workspace.commands[1].attributes={
  "previewUrl": "http://localhost:54321"
}

workspace.commands[2].name="stop"
workspace.commands[2].commandLine='sudo docker run --rm -t -v /var/run/docker.sock:/var/run/docker.sock --env CHE_SERVER_CONTAINER_NAME="che-in-che-server" eclipse/che-launcher stop'

workspace.commands[3].name="kill"
workspace.commands[3].commandLine="sudo docker rm -f che-in-che-server"

# Name of the workspace
workspace.name="che"

# Memory for this workspace
workspace.ram=3092

# Configure project properties
workspace.projects[0].type = "maven"

Add Typescript to Chefile

Chefile is authored as Typescript. While it looks like a simple name=value property file, it’s actually written entirely in Typescript using variable=assignment syntax. This means that you can add in valid TypeScript for variable assignments, operators, and constructs.

This is essential for development team leads and developer operations teams so that they can dynamically generate the Chefile configuration as part of their continuous development processes. While complicated, this is also a valid Chefile:

var date = new Date();
let es6Date = new Date();

let myMap = new Map();
myMap.set("my-name", my-custom-workspace);
myMap.set("my-ram", 2048);

console.log('first date is', date);
console.log('another date is', es6Date);

console.log("map is", myMap);

workspace.name=getWorkspaceName();
workspace.ram=myMap.get("my-ram");

console.log('first command of workspace is', workspace.commands[0].commandLine);

function getWorkspaceName() {
   return myMap.get("my-name");
}