container components to a devfile
container component type to define an image-based configuration of a container in a workspace. This allows to incorporate custom tools into the workspace. A devfile can contain one or more components of the
container type. The
image attribute identifies the component.
Define a component using the type
components: - name: maven container: image: eclipse/maven-jdk8:latest volumeMounts: - name: mavenrepo path: /root/.m2 env: - name: ENV_VAR value: value endpoints: - name: maven-server targetPort: 3101 protocol: https secure: 'true' exposure: public memoryRequest: 256M memoryLimit: 1536M cpuRequest: 0.1 cpuLimit: 0.5 command: ['tail'] args: ['-f', '/dev/null']A minimal
schemaVersion: 2.1.0 metadata: name: mydevfile components: - name: go container: image: golang memoryLimit: 512Mi command: ['sleep', 'infinity']
Specify the type of component using the
containerattribute. Use the
imageattribute to specify the image for the component. When defining the
image, use container naming conventions. For example, the
imageattribute in the preceding example refers to the
containercomponent to augment the image with additional resources and information to allow for integrating the tooling provided by the image with the application that consumes the devfile, for example, Eclipse Che.
Mounting project sources
containercomponent to have access to the project sources, you must set the
schemaVersion: 2.1.0 metadata: name: mydevfile components: - name: go container: image: golang memoryLimit: 512Mi mountSources: true command: ['sleep', 'infinity']
The sources is mounted on a location stored in the
PROJECTS_ROOTenvironment variable that is made available in the running container of the image. This location defaults to
sourceMappingis defined in the container, it overrides the 'PROJECT_ROOT' value if present and mounts the source to the path defined by
commandattribute of the
containertype to modify the
entrypointcommand of the container created from the image. When a devfile is used in Eclipse Che, the container runs indefinitely, so the user can consistently connect to it and execute commands in it. The availability of the
sleepcommand and the support for the
infinityargument depend on the base image used in the particular images.