feat(publish): example publishing to some remote registry
This commit is contained in:
parent
3c8e872e6e
commit
e74b8cc185
2 changed files with 40 additions and 1 deletions
27
README.md
27
README.md
|
@ -74,8 +74,33 @@ as the `source` parameter of that function.
|
|||
> becomes
|
||||
>
|
||||
> ```shell
|
||||
> dagger call build --source=. as-service up --ports=8080:8080
|
||||
> dagger call build --source=. as-service up --ports=8080:9000
|
||||
> ```
|
||||
|
||||
> After running a dagger command the Dagger Engine stays alive as a local
|
||||
> container waiting for the next call.
|
||||
|
||||
> The [Cookbook](https://docs.dagger.io/cookbook) does contain a lot of
|
||||
> extremely useful patterns on how to handle builds and containers. More
|
||||
> importantly, it showcases ways to debug everyday problems when working on
|
||||
> container builds, see `temrinal()`, `File.contents()`
|
||||
|
||||
Run `golangci-lint`:
|
||||
|
||||
```shell
|
||||
dagger call lint --source=.
|
||||
```
|
||||
|
||||
Run trivy:
|
||||
|
||||
```shell
|
||||
dagger call security-scan --source=.
|
||||
```
|
||||
|
||||
> Trivy is setup as a dagger module. Modules are most of the time simple
|
||||
> wrappers instructing container images with some convenience functions. There
|
||||
> is actually not too much magic here.
|
||||
|
||||
> Modules in dagger can be written in Go, Python, or Typescript. Either way,
|
||||
> they are usable in any other language, e.g. a Python module can be used in a
|
||||
> Typescript config. The proper API functions are exposed on the `dag` object.
|
||||
|
|
|
@ -59,6 +59,20 @@ class HelloDagger {
|
|||
.withExec(["golangci-lint", "run", "-v"]);
|
||||
}
|
||||
|
||||
@func()
|
||||
async publish(source: Directory, target?: string): Promise<string> {
|
||||
// publish can only push to external registries
|
||||
// to publish to your local docker, you have to export the tarball and use `docker load`
|
||||
|
||||
// This example is somewhat useless as one could just chain `publish` to `call build`
|
||||
|
||||
// publish automatically picks up the local auth from the host
|
||||
// otherwise, use `withRegistryAuth()`
|
||||
return this.build(source).publish(
|
||||
target ?? "mtr.devops.telekom.de/patrick_sy/hello-dagger:latest",
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a ready-to-use development environment
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue