Skip to content

Commit f433c40

Browse files
committed
Update to the last dagger version
Signed-off-by: Jean-Christophe Sirot <jcsirot@gmail.com>
1 parent 883f89e commit f433c40

File tree

4 files changed

+57
-16
lines changed

4 files changed

+57
-16
lines changed

.github/workflows/deploy-with-dagger.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
- name: Checkout
1111
uses: actions/checkout@v4
1212

13-
- name: Build, publish image
13+
- name: Build and publish image
1414
id: publish
1515
env:
1616
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
@@ -22,7 +22,7 @@ jobs:
2222
args: publish --aws-access-key-id=env://AWS_ACCESS_KEY_ID --aws-secret-access-key=env://AWS_SECRET_ACCESS_KEY
2323
cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN }}
2424

25-
- name: Build, publish image
25+
- name: Deploy to K8S
2626
env:
2727
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
2828
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

ci/pom.xml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,27 @@
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66

7-
<groupId>io.dagger.modules.ci</groupId>
7+
<groupId>io.dagger.modules.daggermodule</groupId>
88
<artifactId>ci</artifactId>
99
<version>1.0-SNAPSHOT</version>
1010
<name>ci</name>
1111

1212
<properties>
1313
<maven.compiler.release>17</maven.compiler.release>
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+
<dagger.module.deps>0.16.3-ci-module</dagger.module.deps>
1516
</properties>
1617

1718
<dependencies>
1819
<dependency>
1920
<groupId>io.dagger</groupId>
2021
<artifactId>dagger-java-sdk</artifactId>
21-
<version>1.0.0-SNAPSHOT</version>
22+
<version>${dagger.module.deps}</version>
2223
</dependency>
2324
<dependency>
2425
<groupId>io.dagger</groupId>
2526
<artifactId>dagger-java-annotation-processor</artifactId>
26-
<version>1.0.0-SNAPSHOT</version>
27+
<version>${dagger.module.deps}</version>
2728
<scope>provided</scope>
2829
</dependency>
2930
<dependency>
@@ -63,6 +64,10 @@
6364
<version>3.3.1</version>
6465
</plugin>
6566
<plugin>
67+
<!--
68+
This plugin configuration is required by Dagger to generate the module.
69+
Please do not remove or modify it.
70+
-->
6671
<artifactId>maven-compiler-plugin</artifactId>
6772
<version>3.13.0</version>
6873
<configuration>
@@ -71,7 +76,7 @@
7176
<path>
7277
<groupId>io.dagger</groupId>
7378
<artifactId>dagger-java-annotation-processor</artifactId>
74-
<version>1.0.0-SNAPSHOT</version>
79+
<version>${dagger.module.deps}</version>
7580
</path>
7681
</annotationProcessorPaths>
7782
<annotationProcessors>
@@ -108,6 +113,35 @@
108113

109114
<plugins>
110115
<plugin>
116+
<!--
117+
This plugin configuration helps VS Code editor (and others) to find
118+
the generated code created by `dagger init` and `dagger develop` and
119+
helps for code completion.
120+
-->
121+
<groupId>org.codehaus.mojo</groupId>
122+
<artifactId>build-helper-maven-plugin</artifactId>
123+
<version>3.3.0</version>
124+
<executions>
125+
<execution>
126+
<id>add-generated-sources</id>
127+
<goals>
128+
<goal>add-source</goal>
129+
</goals>
130+
<configuration>
131+
<sources>
132+
<source>${project.build.directory}/generated-sources/dagger-io</source>
133+
<source>${project.build.directory}/generated-sources/dagger-module</source>
134+
<source>${project.build.directory}/generated-sources/entrypoint</source>
135+
</sources>
136+
</configuration>
137+
</execution>
138+
</executions>
139+
</plugin>
140+
<plugin>
141+
<!--
142+
This plugin configuration is required by Dagger to generate the module.
143+
Please do not remove or modify it.
144+
-->
111145
<groupId>org.apache.maven.plugins</groupId>
112146
<artifactId>maven-shade-plugin</artifactId>
113147
<version>3.5.0</version>

ci/src/main/java/io/dagger/modules/ci/Ci.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.dagger.modules.ci;
22

3+
import static io.dagger.client.Dagger.dag;
4+
35
import io.dagger.client.AwsCli;
46
import io.dagger.client.CacheVolume;
57
import io.dagger.client.Client.AwsCliArguments;
@@ -10,17 +12,21 @@
1012
import io.dagger.client.Directory.DockerBuildArguments;
1113
import io.dagger.client.Platform;
1214
import io.dagger.client.Secret;
13-
import io.dagger.module.AbstractModule;
15+
import io.dagger.client.engineconn.Connection;
1416
import io.dagger.module.annotation.Default;
1517
import io.dagger.module.annotation.DefaultPath;
1618
import io.dagger.module.annotation.Function;
1719
import io.dagger.module.annotation.Object;
1820
import java.util.List;
1921
import java.util.concurrent.ExecutionException;
22+
import org.slf4j.Logger;
23+
import org.slf4j.LoggerFactory;
2024

2125
/** Ci main object */
2226
@Object
23-
public class Ci extends AbstractModule {
27+
public class Ci {
28+
29+
static final Logger LOG = LoggerFactory.getLogger(Connection.class);
2430

2531
private static final List<String> ARCHS = List.of("amd64", "arm64");
2632

@@ -51,6 +57,7 @@ public Container buildImage(@DefaultPath(".") Directory source)
5157
private List<Container> buildImageMultiarch(Directory source, List<String> variants) {
5258
List<Container> images = variants.stream().map(platform -> {
5359
try {
60+
LOG.info("Building image for {}", platform);
5461
return buildImage(source, platform);
5562
} catch (ExecutionException | DaggerQueryException | InterruptedException e) {
5663
throw new RuntimeException(e);
@@ -80,14 +87,14 @@ private Container buildImage(Directory source, String platform)
8087
public String publish(@DefaultPath(".") Directory source, Secret awsAccessKeyId,
8188
Secret awsSecretAccessKey, @Default("eu-west-1") String region)
8289
throws ExecutionException, DaggerQueryException, InterruptedException {
83-
AwsCli awsCli = dag.awsCli()
90+
AwsCli awsCli = dag().awsCli()
8491
.withRegion(region)
8592
.withStaticCredentials(awsAccessKeyId, awsSecretAccessKey);
8693
Secret token = awsCli.ecr().getLoginPassword();
8794
String accountId = awsCli.sts().getCallerIdentity().account();
8895
String address = "%s.dkr.ecr.%s.amazonaws.com/parisjug-dagger-demo/translate-api:%s"
89-
.formatted(accountId, region, dag.gitInfo(source).commitHash().substring(0, 8));
90-
dag.container()
96+
.formatted(accountId, region, dag().gitInfo(source).commitHash().substring(0, 8));
97+
dag().container()
9198
.withRegistryAuth(address, "AWS", token)
9299
.publish(address, new PublishArguments()
93100
.withPlatformVariants(buildImageMultiarch(source, ARCHS)));
@@ -108,11 +115,11 @@ public String publish(@DefaultPath(".") Directory source, Secret awsAccessKeyId,
108115
public String deploy(@DefaultPath(".") Directory source, String image, String clusterName,
109116
Secret awsAccessKeyId, Secret awsSecretAccessKey, @Default("eu-west-1") String region)
110117
throws ExecutionException, DaggerQueryException, InterruptedException {
111-
Container deployerCtr = dag.container().from("alpine")
118+
Container deployerCtr = dag().container().from("alpine")
112119
.withExec(List.of("apk", "add", "aws-cli", "kubectl"));
113120
String appYaml = source.file("src/main/kube/app.yaml").contents()
114121
.replace("${IMAGE_TAG}", image);
115-
return dag.awsCli(new AwsCliArguments().withContainer(deployerCtr))
122+
return dag().awsCli(new AwsCliArguments().withContainer(deployerCtr))
116123
.withRegion(region)
117124
.withStaticCredentials(awsAccessKeyId, awsSecretAccessKey)
118125
.exec(List.of("eks", "update-kubeconfig", "--name", clusterName))
@@ -124,8 +131,8 @@ public String deploy(@DefaultPath(".") Directory source, String image, String cl
124131

125132
/** Build a ready-to-use development environment */
126133
private Container buildEnv(Directory source) {
127-
CacheVolume mavenCache = dag.cacheVolume("m2");
128-
return dag
134+
CacheVolume mavenCache = dag().cacheVolume("m2");
135+
return dag()
129136
.container()
130137
.from("maven:3-eclipse-temurin-21")
131138
.withDirectory("/src", source)

dagger.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ci",
3-
"engineVersion": "v0.16.1",
3+
"engineVersion": "v0.16.3",
44
"sdk": {
55
"source": "java"
66
},

0 commit comments

Comments
 (0)