Back to Dagger

Publish the container image

docs/versioned_docs/version-0.16.3/ci/quickstart/publish.mdx

0.21.53.1 KB
Original Source

import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem";

Dagger for CI: Quickstart

Publish the container image

The end stage of the example pipeline is the publish stage, which publishes the container image to a registry.

Inspect the Dagger Function

<Tabs groupId="language"> <TabItem value="Go">
go
</TabItem> <TabItem value="Python">
python
</TabItem> <TabItem value="TypeScript">
typescript
</TabItem> <TabItem value="PHP">
php
</TabItem> <TabItem value="Java">
java
</TabItem> </Tabs>

Just as you can call Dagger Functions individually from the CLI, you can also call (and combine) them using a programming language. This Dagger Function is an example. It is a higher-level function which orchestrates the Dagger Functions in previous sections and the core Dagger API to:

  • run the application's tests and return the results;
  • build and return a container image of the final application;
  • publish the container image to a registry and return the image identifier.

:::tip COMBINING DAGGER FUNCTIONS There are various reasons why you might want to write Dagger Functions that call other Dagger Functions. A common reason is that when developing locally, it's quicker and easier to trigger your pipeline using a single command (dagger call publish ...) instead of multiple commands (dagger call test ... && dagger call build ... && ...). :::

Call the Dagger Function

Call the Dagger Function:

shell
dagger call publish --source=.

You should see the application being tested, built, and published to the ttl.sh container registry:

You can test the published container image by pulling and running it with docker run:

:::tip FUNCTION CHAINING Function chaining works the same way, whether you're writing Dagger Function code using a Dagger SDK or invoking a Dagger Function using the Dagger CLI. The following are equivalent:

<Tabs groupId="language"> <TabItem value="Go">
go
</TabItem> <TabItem value="Python">
python
</TabItem> <TabItem value="TypeScript">
typescript
</TabItem> <TabItem value="PHP">
php
</TabItem> <TabItem value="Java">
java
</TabItem> <TabItem value="Dagger CLI"> ```shell # all equivalent dagger call base with-exec --args apk,add,bash,git publish --address="ttl.sh/bar" dagger call build publish --address="ttl.sh/bar" dagger call build-and-publish ``` </TabItem> </Tabs> :::