Using Dockerfile For Python Function Task
In Truefoundry workflow you can pass the dockerfile path in the task config, this is useful when you want to install a binary and use it in your python function task like using a jq command, etc.
TaskDockerFileBuild
- To use dockerfile for python task, we need to import
TaskDockerFileBuild
and use it inPythonTaskConfig
.
Example
In this guide, we will see how to write a Python function task with a dockerfile. In this example, we will take a string as an input and then will calculate the SHA56 hash from the input. We will be passing the
Prerequisites
Before you proceed with the guide, make sure you have the following:
- Truefoundry CLI: Set up and configure the TrueFoundry CLI tool on your local machine by following the Setup for CLI guide.
- Workspace: To deploy your workflow, you’ll need a workspace. If you don’t have one, you can create it using this guide: Creating a Workspace or seek assistance from your cluster administrator.
Creating the workflow
Create a workflow.py where we will write the code for our workflow and place it in the project root directory with your Dockerfile.
Your directory structure will then appear as follows:
Dockerfile
workflow.py
- As you can see, we have given the dockerfile_path argument in PythonTaskConfig where the path to the docker file is used as its value.
Now run the below command in the terminal to deploy your workflow, replace <workfspace-fqn>
with the workspace fqn which you can find on the UI.