container components to a devfile
A component type that allows to define a container image-based configuration of a container in a workspace. A devfile can contain one or more component(s) of the
container type. The
container type of component brings in custom tools into the workspace. The component is identified by its image.
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 configuration: protocol: tcp scheme: http secure: 'true' public: 'true' discoverable: 'false' memoryLimit: 1536M command: ['tail'] args: ['-f', '/dev/null']A minimal
schemaVersion: 2.0.0 metadata: name: MyDevfile components: - name: go container: image: golang memoryLimit: 512Mi command: ['sleep', 'infinity']
It specifies the type of the component,
imageattribute names the image to be used for the component using the usual Docker naming conventions, that is, the above
imageattribute is equal to
containercomponent has many features that enable augmenting the image with additional resources and information needed for meaningful integration of the tool provided by the image with Devfile.
Mounting project sources
containercomponent to have access to the project sources, you must set the
schemaVersion: 2.0.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
containeralong with other arguments, is used to modify the
entrypointcommand of the container created from the image. In Devfile the container is needed to run indefinitely so that you can connect to it and execute arbitrary commands in it at any time. Because the availability of the
sleepcommand and the support for the
infinityargument for it is different and depends on the base image used in the particular images, Devfile cannot insert this behavior automatically on its own. However, you can take advantage of this feature to, for example, start up necessary servers with modified configurations, etc.