Skip to content

Commit c01db15

Browse files
committed
WIP Dagger CU Replace earthly - redo the CI #1056
1 parent fc2927f commit c01db15

File tree

9 files changed

+157
-1162
lines changed

9 files changed

+157
-1162
lines changed

.dagger/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/sdk/** linguist-generated

.dagger/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/sdk
2+
/**/node_modules/**
3+
/**/.pnpm-store/**

.dagger/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "module",
3+
"dependencies": {
4+
"typescript": "^5.5.4"
5+
},
6+
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
7+
}

.dagger/src/index.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import {
2+
dag,
3+
Container,
4+
Directory,
5+
object,
6+
func,
7+
argument,
8+
} from "@dagger.io/dagger";
9+
10+
@object()
11+
export class AtomicServer {
12+
/**
13+
* Publish the application container after building and testing it on-the-fly
14+
*/
15+
@func()
16+
async publish(
17+
@argument({ defaultPath: "/" }) source: Directory
18+
): Promise<string> {
19+
await this.test(source);
20+
return await this.build(source).publish(
21+
"ttl.sh/hello-dagger-" + Math.floor(Math.random() * 10000000)
22+
);
23+
}
24+
25+
/**
26+
* Build the application container
27+
*/
28+
@func()
29+
build(@argument({ defaultPath: "/" }) source: Directory): Container {
30+
const build = this.buildEnv(source)
31+
.withExec(["npm", "run", "build"])
32+
.directory("./dist");
33+
return dag
34+
.container()
35+
.from("nginx:1.25-alpine")
36+
.withDirectory("/usr/share/nginx/html", build)
37+
.withExposedPort(80);
38+
}
39+
40+
/**
41+
* Return the result of running unit tests
42+
*/
43+
@func()
44+
async test(
45+
@argument({ defaultPath: "/" }) source: Directory
46+
): Promise<string> {
47+
return this.buildEnv(source)
48+
.withExec(["npm", "run", "test:unit", "run"])
49+
.stdout();
50+
}
51+
52+
/**
53+
* Build a ready-to-use development environment
54+
*/
55+
@func()
56+
buildEnv(@argument({ defaultPath: "/" }) source: Directory): Container {
57+
const nodeCache = dag.cacheVolume("node");
58+
return dag
59+
.container()
60+
.from("node:21-slim")
61+
.withDirectory("/src", source)
62+
.withMountedCache("/root/.npm", nodeCache)
63+
.withWorkdir("/src")
64+
.withExec(["npm", "install"]);
65+
}
66+
}

.dagger/tsconfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2022",
4+
"moduleResolution": "Node",
5+
"experimentalDecorators": true,
6+
"strict": true,
7+
"skipLibCheck": true,
8+
"paths": {
9+
"@dagger.io/dagger": ["./sdk/index.ts"],
10+
"@dagger.io/dagger/telemetry": ["./sdk/telemetry.ts"]
11+
}
12+
}
13+
}

.dagger/yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
typescript@^5.5.4:
6+
version "5.8.3"
7+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.8.3.tgz#92f8a3e5e3cf497356f4178c34cd65a7f5e8440e"
8+
integrity sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==

.dockerignore

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Dependencies
2+
node_modules
3+
.pnpm-store
4+
.npm
5+
.yarn
6+
.yarn-cache
7+
8+
# Build outputs
9+
artifact
10+
dist
11+
build
12+
docs/book
13+
target
14+
*.o
15+
*.so
16+
*.dylib
17+
18+
# Development files
19+
.git
20+
.github
21+
.vscode
22+
.idea
23+
*.swp
24+
*.swo
25+
.DS_Store
26+
27+
# Test files
28+
coverage
29+
.nyc_output
30+
test-results
31+
playwright-report
32+
33+
# Logs
34+
*.log
35+
npm-debug.log*
36+
yarn-debug.log*
37+
yarn-error.log*
38+
39+
# Environment files
40+
.env
41+
.env.*
42+
!.env.example
43+
44+
# Cache directories
45+
.cache
46+
.temp
47+
.tmp
48+
49+
# Documentation

0 commit comments

Comments
 (0)