FileMount

FileMount

For any deployment, in case you want to bind some non-sensitive configuration artifacts such as:

  • configuration files
  • command-line arguments
  • environment variables

to your Deployment so that you can easily access them at runtime without having to create a new Deployment, you can use FileMount.

The Key parameters to be specified are:

  • mount_dir:
    By this you can specify at which directory your file/configurations should be stored.
  • data:
    This specifies the configuration itself.

Setting FileMount for truefoundry applications

# `Service` and `Job`, both have a `file_mount` argument.

import logging

from servicefoundry import Build, Service, DockerFileBuild, FileMount

logging.basicConfig(level=logging.INFO)
service = Service(
    name="service",
    image=Build(build_spec=DockerFileBuild()),
    ports=[{"port": 8501}],
    file_mount=FileMount(
      mount_dir="/tmp",
      data={"foo": "bar", "foo2": "bar2" }
    )
)
service.deploy(workspace_fqn="YOUR_WORKSPACE_FQN")
#You can defined the file_mount fields as a key-value pair under the `file_mount` field.

name: service
components:
  - name: service
    type: service
    image:
      type: build
      build_source:
        type: local
      build_spec:
        type: dockerfile
    ports:
     - port: 8501
    file_mount: # You can use this block in `job` too.
      mount_dir: "/tmp"
      data:
      	- foo: bar
        - foo2: bar2