# App Build Process

This tutorial walks you through the following features of the DNAnexus app build infrastructure:

* The `dxapp.json` file, a central point for information about your app
* The `/resources` directory, where you can include files to be loaded onto the workers which execute your app
* The option to build your app remotely, needed when building from a system not compatible with Ubuntu 24.04 or 20.04

For more information about the worker environment where your app runs, and on how to specify runtime dependencies for your app, see the [Execution Environment Reference](/developer/apps/execution-environment.md).

## App Directory Structure

DNAnexus applets and apps are compiled using the `dx build` and `dx build --create-app` utilities in the [DNAnexus SDK](/downloads.md), which take code on your local workstation and upload it into an object on the platform. The SDK expects each program to reside in a directory with a specific structure, which looks like this:

```
MyApp
├── dxapp.json
├── Readme.md
├── Readme.developer.md
├── resources
│   └── ...
├── src
│   └── ...
└── test
    └── ...
```

### The `dxapp.json` App Metadata File

The file `dxapp.json` is a DNAnexus application metadata file. Its presence in a directory indicates to DNAnexus tools that it contains DNAnexus app source code, marking it as a project directory. See [`dxapp.json`](/developer/apps/app-metadata.md) for a complete description of the app metadata format.

### Readme Files

The `Readme.md` file, if present, is inserted into the `description` field of the app or applet.

The `Readme.developer.md` file, if present, is inserted into the `developerNotes` field of the app or applet.

### The Resources/ Subdirectory

See the section "Building apps from source" below, which describes the relationship between the `resources` subdirectory of your project directory and the resulting app or applet.

## Building an Applet

You can use the following command to load your application into the DNAnexus Platform as an applet:

```shell
dx build MyApp
```

This assumes your applet's source code appears in a directory `MyApp` underneath the current directory.

Before uploading your program to DNAnexus, `dx build` performs the following build steps.

* `./configure` (if a configure script exists)
* `make` (if a Makefile is present)

You can put arbitrary steps in your Makefile to prepare any resources that might be needed by your app at runtime. For example, one module of your app might be written in C++ and therefore would need to be compiled to a library or executable.

### The Resources/ Directory and Its Use

Anything that is present in the `resources/` subdirectory of your app directory is archived after the build step and then unarchived into the root of your execution environment's filesystem at runtime. You can either check files directly into your source repository in the `resources/` subdirectory, or have your build step generate files there, or a combination of the two.

By default, the `PATH` in the environment is the following (it is inherited from Ubuntu's defaults):

```
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
```

As an example, if your Makefile produces a binary and puts it in `resources/usr/bin/bwa` in your source tree, that file is available to your app as `/usr/bin/bwa` at runtime (and you can therefore call it as a subprocess from your entry point method).

While the `resources/` subdirectory is unpacked into the root of the virtual filesystem, your app starts in `/home/dnanexus` as its current working directory. You may therefore want to put files or data in `resources/home/dnanexus` to have them available in the current working directory when your applet starts.

## Next Steps

* See the [Developer Tutorials](/getting-started/developer-tutorials.md) page for language-specific tutorials in a variety of programming languages. These walk you through writing more complex apps in the language of your choice.
* If you want to see more example code, you can use the `dx get` command to reconstruct and download the source directory of open-source apps. Try `dx get app-cloud_workstation` to see a good example. You can find open-source apps with the command below

```shell
dx api system findApps '{"describe":{"fields":{"openSource": true, "name": true}}}' \
  | jq '.results|.[]|select(.describe.openSource)|.describe.name'
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.dnanexus.com/developer/apps/app-build-process.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
