24
Host any Project in Che with Stacks and Chefiles Martin Albisetti (@beuno), bitnami Florent Benoit (@florentbenoit), Codenvy

Host any project in che with stacks & chefiles

Embed Size (px)

Citation preview

Host any Project in Che with Stacks and Chefiles

Martin Albisetti (@beuno), bitnamiFlorent Benoit (@florentbenoit), Codenvy

Hi! I’m Martin Albisetti.

I work for Bitnami as a Senior Software Architect.

Bitnami is the leading provider of up-to-date open source software in the cloud.

Bitnami Che Stacks

● Codeigniter● Express● Laravel● Play for Java● Ruby on Rails● Swift● Symfony

Let’s try out the Express stack

Live demo:Che with a MEAN app

What we saw● Nothing running on my laptop!● Live editing in a remote Che environment (built by Bitnami in

Google Cloud)● A Bitnami development stack ready to use with NodeJS,

Express & MongoDB● Connected with Github and using an integration branch● Jenkins automatically detecting changes and merging into

Master if tests passed

Using Che with Your ProjectCustom stacks and Chefiles

Florent Benoit, Lead developer (codenvy)

Create Stacks In Che DashboardChe provides default set of stacks : workspace runtime

● docker compose stacks (single or multi machines):○ java/mysql, etc.

Add custom stacks

Add A Go Stack

Part 1

Dockerfile

FROM codenvy/ubuntu_jdk8

RUN sudo apt-get update -y && \

sudo apt-get --no-install-recommends -y -q install git

mercurial && sudo mkdir /usr/local/go && wget -qO-

https://storage.googleapis.com/golang/go1.6.linux-amd64.tar.gz

| sudo tar xzf - -C /usr/local/go --strip-components=1

ENV PATH /usr/local/go/bin:$PATH

DockerHub : https://hub.docker.com/r/florentbenoit/golang/

Add A Go Stack

Part 2"image": "florentbenoit/golang"

"id": "my-go-stack",

"name": "My go stack",

"description": "This is my custom go stack",

"tags": [ "Go" ],

"components": [ {

"name": "go",

"version": "1.6"

} ],

Add A Go Stack

Part 3 "commands": [

{

"commandLine": "go run ${explorer.current.file.path}",

"name": "run",

"type": "custom"

}

]

Macros${editor.current.file.name} -- Currently selected file in editor with context${editor.current.file.path} -- Absolute path to the selected file in editor with context${editor.current.file.relpath} -- Path relative to the /projects folder in editor with context${editor.current.project.name} -- Project name of the file currently selected in editor with context${editor.current.project.type} -- Project type of the file currently selected in editor with context

${explorer.current.file.name} -- Currently selected file in project tree${explorer.current.file.path} -- Absolute path to the selected file in project tree${explorer.current.file.relpath} -- Path relative to the /projects folder in project tree${explorer.current.project.name} -- Project name of the file currently selected in explorer${explorer.current.project.type} -- Project type of the file currently selected in explorer

${server.<name>} -- Returns protocol, hostname and port of an internal server${server.<name>.protocol} -- Returns protocol of a server registered by name${server.<name>.hostname} -- Returns hostname of a server registered by name${server.<name>.port} -- Returns port of a server registered by name

${workspace.name} -- Returns the name of the workspace

${host.name} -- Returns the hostname of the docker daemon${host.ip} -- Returns the IP address of the docker daemon

Docker Compose Stack

"workspaceConfig": {

...

"recipe": {

"content": "services:\n db:\n image: mysql\n

environment:\n MYSQL_DATABASE: petclinic\n ...... \n - db",

"contentType": "application/x-yaml"

"type": "compose"

...

},

services:

db:

image: mysql

environment:

MYSQL_DATABASE: petclinic

mem_limit: 1073741824

dev-machine:

image: codenvy/ubuntu_jdk8

mem_limit: 2147483648

depends_on:

- db

Live Demo: Stacks

Chefile UsagePortable workspace in few seconds:

$ git clone https://github.com/che-samples/web-java-spring-petclinic

$ che dir up

...workspace is booted and ready at http://localhost:8080/che

Chefile DefaultWrite default Chefile in folder where che dir init is called

Defaults:

- Runtime with ubuntu image- Project type : blank- Dummy commands- Memory = 2GB

ChefileSyntaxExample

# Defines name of the workspace

workspace.name = “che”

# Define the Docker image used as workspace's runtime

# This must conform to a Che recipe type:

workspace.runtime.image.location="codenvy/alpine_jdk8"

# Defines memory allocated to the workspace's runtime

workspace.ram = 2048

# Define commands that will be displayed in the IDE

# Commands will appear in the drop down on the toolbar.

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.8080}/"

# A command that will be executed after the workspace is loaded.

# Reference the name of a command defined above.

Workspace.postload.actions[0].script="echo ‘a post-loading command’"

Live Demo: Chefile

Chefile Commandshelp

$ che dir init Create Chefile if not existing$ che dir up Boot Eclipse Che workspace$ che dir status Display status $ che dir down Shutdown Eclipse Che + stop workspace$ che dir destroy Shutdown Eclipse Che + remove workspace$ che dir ssh Connect with ssh to workspace’s runtime

Host a Chefile In Your Github Repository

Host a Chefile In Your Gitlab Repository

Thank You

CheConf2016 Agenda: Up Next

11:00 CheConf Keynote 15:00 Deploying Che to OpenShift

12:00 Language Server Protocol 15:30 Pair Programming in Che

12:30 Host any Project in Che 16:00 Building an IoT IDE with Che

13:30 Docker in Che 16:30 Codenvy: Che for Enterprises

14:00 Extending Che 17:00 Become Part of the Project