Skip to content

Commit a869a93

Browse files
committed
Dagger JS build working
1 parent c01db15 commit a869a93

File tree

4 files changed

+70
-49
lines changed

4 files changed

+70
-49
lines changed

.dagger/src/index.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,51 @@ export class AtomicServer {
6363
.withWorkdir("/src")
6464
.withExec(["npm", "install"]);
6565
}
66+
67+
@func()
68+
buildJS(@argument({ defaultPath: "/browser" }) source: Directory): Container {
69+
const depsContainer = this.getDeps(source.directory("."));
70+
71+
const buildContainer = depsContainer
72+
.withWorkdir("/app")
73+
.withExec(["pnpm", "run", "build"]);
74+
75+
return buildContainer;
76+
}
77+
78+
@func()
79+
private getDeps(source: Directory): Container {
80+
// Create a container with PNPM installed
81+
const pnpmContainer = dag
82+
.container()
83+
.from("node:24")
84+
.withExec(["npm", "install", "--global", "corepack@latest"])
85+
.withExec(["corepack", "enable"])
86+
.withExec(["corepack", "prepare", "pnpm@latest-10", "--activate"])
87+
.withWorkdir("/app");
88+
89+
// Copy workspace files first
90+
const workspaceContainer = pnpmContainer
91+
.withFile("/app/package.json", source.file("package.json"))
92+
.withFile("/app/pnpm-lock.yaml", source.file("pnpm-lock.yaml"))
93+
.withFile("/app/pnpm-workspace.yaml", source.file("pnpm-workspace.yaml"))
94+
.withFile(
95+
"/app/data-browser/package.json",
96+
source.file("data-browser/package.json")
97+
)
98+
.withFile("/app/lib/package.json", source.file("lib/package.json"))
99+
.withFile("/app/react/package.json", source.file("react/package.json"))
100+
.withFile("/app/svelte/package.json", source.file("svelte/package.json"))
101+
.withFile("/app/cli/package.json", source.file("cli/package.json"));
102+
103+
// Install dependencies
104+
const depsContainer = workspaceContainer.withExec([
105+
"sh",
106+
"-c",
107+
"yes | pnpm install --frozen-lockfile --shamefully-hoist",
108+
]);
109+
110+
// Copy the rest of the source
111+
return depsContainer.withDirectory("/app", source);
112+
}
66113
}

.dockerignore

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1 @@
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
1+

CONTRIBUTING.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Check out the [Roadmap](https://docs.atomicdata.dev/roadmap.html) if you want to
1616
- [Running \& compiling](#running--compiling)
1717
- [Running locally (with local development browser)](#running-locally-with-local-development-browser)
1818
- [IDE setup (VSCode)](#ide-setup-vscode)
19+
- [Using Dagger](#using-dagger)
1920
- [Compilation using Earthly](#compilation-using-earthly)
2021
- [Improve local compilation speed](#improve-local-compilation-speed)
2122
- [Cross compilation](#cross-compilation)
@@ -59,6 +60,17 @@ That doesn't mean that you should, too, but it means you're less likely to run i
5960
- **Debugging**: Install the `CodeLLDB` plugin, and press F5 to start debugging. Breakpoints, inspect... The good stuff.
6061
- **Extensions**: That same directory will give a couple of suggestions for extensions to install.
6162

63+
### Using Dagger
64+
65+
Dagger is a tool that's used for building the project.
66+
The `.dagger` directory and the `dagger.json` file contain most of the configuration.
67+
Install the Dagger CLI from [here](https://docs.dagger.io/install/) and run the `dagger` command in the root of the project.
68+
Then you can run the commands from the `.dagger/src/index.ts` file, e.g. `dagger call build-browser`.
69+
Add `-i` to the command to run in interactive mode, add `--output` to save the output to a folder.
70+
Note that the camelCase functions in the `index.ts` file are converted to kebab-case commands in the Dagger API.
71+
72+
Check out the [Dagger docs](https://docs.dagger.io/) for more information.
73+
6274
### Compilation using Earthly
6375

6476
There are `earthfile`s in `browser` and in `atomic-server`.

dagger.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,15 @@
44
"sdk": {
55
"source": "typescript"
66
},
7+
"exclude": [
8+
"node_modules",
9+
"dist",
10+
"build",
11+
".env",
12+
".git",
13+
".github",
14+
".husky",
15+
".vscode"
16+
],
717
"source": ".dagger"
818
}

0 commit comments

Comments
 (0)