A Funfile contains the commands that specify the steps to produce Function Compute deliverables such as the content that must be published after you develop, package, and compile a project. Funcraft runs the commands in the Funfile to produce the deliverables. This topic describes how to use a Funfile to install third-party dependencies.
Prerequisites
- Funcraft is installed and configured. For more information, see the "Step 1: Install Funcraft" section of the Install Funcraft topic and the Configure Funcraft topic.
- Docker is installed. For more information, see the "Step 2: (Optional) Install Docker" section of the Install Funcraft topic.
Syntax supported by Funfiles
Funfiles support specific commands in Dockerfiles, such as the COPY, RUN, ENV, USER, and WORKDIR commands A Dockerfile is used to build a Docker image, whereas a Funfile is used to produce Function Compute deliverables. You can install the rlang package to check the commands that are supported by Funfiles. For more information, see rlang.
To use a Funfile to install third-party dependencies, add fun-install
before the original apt-get
and pip
commands, which are used in a Dockerfile, in the Funfile.
Benefits of Funfiles
- Standardized: The commands that are specified in a Funfile to install dependencies help standardize the development process.
- Convenient: You can submit a Funfile instead of specific dependencies to the version control system. This helps maintain function code.
- Native: Funfile commands are similar to native Dockerfile commands, but provide better
user experience. You can test installation commands in an interactive environment
by using the
fun install sbox
command and then write the final installation commands in a Funfile. - Efficient: Funfiles support the cache feature of Dockerfiles. If the changes in a project do not affect Funfiles, Function Compute can skip related commands in the Funfiles based on the cached data. This accelerates the execution of Funfiles and improves development efficiency.
Procedure
- Create a Funfile.
- Use the Funfile to install a dependent pip package.
References
The dependencies installed by using the fun install command are installed to the code directory. You can use the fun local command to perform on-premises debugging and use the fun deploy command to deploy your project to the cloud.