Skip to main content

Quickstart

Build the application

If your application passes all its tests, the typical next step is to build it.

So, let's update the previous pipeline and add a build step to it, by running npm run build.

tip

The npm run build command is appropriate for a React application, but other applications are likely to use different commands. Modify your Dagger pipeline accordingly.

  • It invokes the Container.WithExec() method again, this time to define the command npm run build in the container.
  • It obtains a reference to the build/ directory in the container with the Container.Directory() method. This method returns a Directory object.
  • It writes the build/ directory from the container to the host using the Directory.Export() method.

Run the pipeline by executing the command below from the application directory:

dagger run go run ci/main.go

After Dagger resolves the pipeline, the built application is available in a new build/ sub-directory of the application directory. Confirm this by executing the tree command in the application directory, as shown below:

tree build
build/
├── asset-manifest.json
├── favicon.ico
├── index.html
├── logo192.png
├── logo512.png
├── manifest.json
├── robots.txt
└── static
├── css
│ ├── main.073c9b0a.css
│ └── main.073c9b0a.css.map
└── js
├── 787.305db8b6.chunk.js
├── 787.305db8b6.chunk.js.map
├── main.5e49019b.js
├── main.5e49019b.js.LICENSE.txt
└── main.5e49019b.js.map

3 directories, 14 files