Asset Build Process
This page describes the structure of an asset source directory and shows you how to begin building an asset bundle.
Asset Directory Structure
A DNAnexus asset can be built using the dx build_asset
utility in the DNAnexus SDK, which builds an asset bundle in an isolated environment. The utility expects a directory with the following structure:
In order to build this asset, run the command dx build_asset asset_name
Each component of the directory is described in detail below.
Asset Metadata
The dxasset.json
file contains essential metadata that define the asset. This file is required to build an asset and therefore must be present in the asset source directory. The following is a sample dxasset.json
file:
Additional Resources
If anything is present in the resources/
subdirectory of the asset directory, it will be archived by dx build_asset
and unpacked into the root of a clean Ubuntu installation during the asset build process. Files here can be propagated directly into the asset, or they can be used to build other artifacts that are themselves propagated into the asset.
For example, if you have some C or C++ source files that should be compiled so that their binary output can be included in the asset bundle, you can do one of the following:
Put your source files somewhere in the
resources/
directory, such asresources/example_dir/
.Invoke your build process from the Makefile included in the asset source directory (see below). In the asset build environment, your source files are available in the directory
/example_dir
.
By default, the PATH in the execution environment (inherited from Ubuntu's defaults) is the following:
Makefile
The optional Makefile contains instructions to build and copy additional resources required by the asset. If present in the asset source directory, the Makefile is copied to the working directory /home/dnanexus
of the asset build environment and executed. Here is an example Makefile that downloads and installs various resources:
To learn more about the Makefile in general, see the Wikipedia page.
Building an Asset
Assuming the directory asset_name
contains a dxasset.json
file, you can use the following command to build your asset:
A virtual worker starts a new DNAnexus job in order to provide an isolated build environment in which the following steps are performed:
A snapshot is taken of the worker's filesystem. During this process, all the directories, files, and symbolic links are recorded, except those mentioned in the
excludeResource
field of thedxasset.json
file. Files in directories matching the following paths are excluded:/proc*
,/tmp*
,/run*
,/boot*
,/home/dnanexus*
,/sys*
. On Ubuntu 20.04 paths/bin,/sbin
are also excluded as they are symlinks to/usr/bin,/usr/sbin
Any packages mentioned in the
execDepends
field of thedxasset.json
are installed in the worker's execution environment.If a
resources/
directory is present in the asset source directory, its contents are copied to the root directory/
of the worker's execution environment.If a Makefile is present in the asset source directory, it is copied to the
/home/dnanexus
on the worker and executed assudo make -C /home/dnanexus
.A second snapshot of the worker's execution environment is taken.
All new and modified (files with different timestamps from those on the earlier snapshot) files are packaged in the resulting asset bundle.
Last updated