Components
Adding container component
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.
Prerequisites
Procedure
Define a component using the type
container
.A container component
devfile.yamlcomponents: - 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 container component
devfile.yamlschemaVersion: 2.1.0 metadata: name: mydevfile components: - name: go container: image: golang memoryLimit: 512Mi command: ['sleep', 'infinity']
It specifies the type of the component,
container
and theimage
attribute names the image to be used for the component using the usual Docker naming conventions, that is, the aboveimage
attribute is equal todocker.io/library/golang:latest
.Mounting project sources
For the
container
component to have access to the project sources, you must set themountSources
attribute totrue
.devfile.yamlschemaVersion: 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_ROOT
environment variable that is made available in the running container of the image. This location defaults to/projects
. IfsourceMapping
is defined in the container, it overrides the PROJECT_ROOT value if present and mounts the source to the path defined bysourceMapping
.Container Entrypoint
Use the
command
attribute of thecontainer
type to modify theentrypoint
command of the container created from the image. The availability of thesleep
command and the support for theinfinity
argument depend on the base image used in the particular images.