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
.
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 commandnpm run build
in the container. - It obtains a reference to the
build/
directory in the container with theContainer.Directory()
method. This method returns aDirectory
object. - It writes the
build/
directory from the container to the host using theDirectory.Export()
method.
Run the pipeline by executing the command below from the application directory:
go run ci/main.go
This revised pipeline does everything described in the previous step, and then performs the following additional operations:
- It invokes the
Container.withExec()
method again, this time to define the commandnpm run build
in the container. - It obtains a reference to the
build/
directory in the container with theContainer.directory()
method. This method returns aDirectory
object. - It writes the
build/
directory from the container to the host using theDirectory.export()
method.
Run the pipeline by executing the command below from the application directory:
node ci/index.mjs
This revised pipeline does everything described in the previous step, and then performs the following additional operations:
- It invokes the
Container.with_exec()
method again, this time to define the commandnpm run build
in the container. - It obtains a reference to the
build/
directory in the container with theContainer.directory()
method. This method returns aDirectory
object. - It writes the
build/
directory from the container to the host using theDirectory.export()
method.
Run the pipeline by executing the command below from the application directory:
python ci/main.py
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.a03ce25e.js
│ ├── main.a03ce25e.js.LICENSE.txt
│ └── main.a03ce25e.js.map
└── media
└── logo.6ce24c58023cc2f8fd88fe9d219db6c6.svg
- Go
- Node
- Python