@@ -59,18 +59,6 @@ get-local-hermes:
59
59
#
60
60
# This creates Rust structs, enums, and functions that allow WASM modules
61
61
# to interact with Hermes APIs like HTTP handling, logging, storage, etc.
62
- #
63
- # Multi-Module Architecture:
64
- # 🔗 SHARED BINDINGS: All modules use the same generated hermes.rs bindings
65
- # 📋 Common interfaces: HTTP, logging, storage, configuration, security
66
- # 🎯 Module-specific APIs: Each module can expose its own interfaces to others
67
- # ♻️ Reusable: Generated once, used by all modules in the application
68
- #
69
- # Future Module Examples:
70
- # - Authentication module: Uses shared HTTP + adds auth-specific interfaces
71
- # - Database module: Uses shared logging + adds database-specific interfaces
72
- # - Caching module: Uses shared storage + adds cache-specific interfaces
73
- #
74
62
# Build Process:
75
63
# 1. Uses WASI build environment with WIT tools pre-installed
76
64
# 2. Processes WIT files to generate corresponding Rust code
@@ -88,135 +76,11 @@ gen-bindings:
88
76
# NOTE: In multi-module apps, this same hermes.rs is copied to each module's src/
89
77
SAVE ARTIFACT hermes.rs AS LOCAL athena/modules/http-proxy/src/hermes.rs
90
78
91
- # HTTP Proxy WASM Module Build
92
- # =============================
93
- # Compiles the HTTP proxy Rust code into a WebAssembly module using the wasm32-wasip2 target.
94
- # This creates a sandboxed, portable component that can run in the Hermes runtime.
95
- #
96
- # 🌟 FIRST MODULE EXAMPLE - This demonstrates the pattern for building WASM modules
97
- # 📈 SCALABLE PATTERN: Additional modules follow this same build template:
98
- #
99
- # Future Module Build Targets (following this pattern):
100
- # +build-auth-module: Authentication and authorization (JWT, OAuth, API keys)
101
- # +build-database-module: Database connectivity and ORM functionality
102
- # +build-cache-module: Caching layer with Redis/Memcached support
103
- # +build-notification-module: Email, SMS, push notifications
104
- # +build-analytics-module: Request tracking, metrics, and reporting
105
- # +build-rate-limit-module: Request throttling and DDoS protection
106
- #
107
- # Multi-Module Benefits:
108
- # ✅ Independent development and testing of each module
109
- # ✅ Selective updates - rebuild only changed modules
110
- # ✅ Parallel compilation for faster overall build times
111
- # ✅ Modular deployment - enable/disable features per environment
112
- # ✅ Clear separation of concerns and responsibilities
113
- #
114
- # Build Pipeline:
115
- # 1. Set up Rust toolchain with WASM target support
116
- # 2. Copy source code and dependencies into build container
117
- # 3. Generate and integrate WIT bindings (shared across modules)
118
- # 4. Compile to optimized WASM binary
119
- # 5. Export artifacts for packaging
120
- #
121
- # Compilation Target: wasm32-wasip2 (WebAssembly System Interface Preview 2)
122
- # Optimization: Release mode with size optimizations (opt-level = "z", lto = true)
123
- # Output: http_proxy.wasm - Executable WebAssembly module
124
- # Duration: ~3-5 minutes (Rust compilation to WASM)
125
- local-build-http-proxy :
126
- DO rust-ci+SETUP
127
- WORKDIR /app
128
-
129
- # Copy source code and project configuration
130
- COPY --keep-ts --dir http-proxy/src .
131
- COPY http-proxy/Cargo.toml .
132
-
133
- # Integrate generated WIT bindings into the build
134
- COPY +gen-bindings/hermes.rs src/hermes.rs
135
-
136
- # Copy module configuration and metadata files
137
- COPY http-proxy/lib/config.schema.json .
138
- COPY http-proxy/lib/manifest_module.json .
139
- COPY http-proxy/lib/metadata.json .
140
- COPY http-proxy/lib/settings.schema.json .
141
-
142
- # Create the missing config.json file (empty JSON object)
143
- RUN echo '{}' > config.json
144
-
145
- # Download web assets directly to root level
146
- COPY github.com/input-output-hk/catalyst-voices/catalyst_voices+build-web/web .
147
-
148
- # Compile Rust code to WebAssembly
149
- DO rust-ci+CARGO \
150
- --args "build --target wasm32-wasip2 --release" \
151
- --output = "wasm32-wasip2/release/http_proxy.wasm"
152
-
153
- # Create staging directory structure
154
- RUN mkdir -p /staging/www
155
-
156
- # Copy WASM module and JSON config files to root of staging
157
- RUN cp target/wasm32-wasip2/release/http_proxy.wasm /staging/
158
- RUN cp *.json /staging/ || true
159
-
160
- # Copy web assets to www subdirectory
161
- RUN cp -r assets /staging/www/ || true
162
- RUN cp -r canvaskit /staging/www/ || true
163
- RUN cp -r icons /staging/www/ || true
164
-
165
- # Copy all regular files from current directory to staging/www, skip directories
166
- RUN find . -maxdepth 1 -type f -exec cp {} /staging/www/ \; 2> /dev/null || echo "⚠️ Some files may not have been copied"
167
-
168
- # Export build artifacts from staging directory
169
- SAVE ARTIFACT /staging AS LOCAL http-proxy/lib
170
-
171
- # Future Module Build Targets
172
- # ============================
173
- # 🚀 COMING SOON: Additional module build targets following the same pattern as build-http-proxy
174
- #
175
- # Example future targets:
176
- #
177
- # build-auth-module:
178
- # DO rust-ci+SETUP
179
- # WORKDIR /app
180
- # COPY --keep-ts --dir auth-module/src .
181
- # COPY auth-module/Cargo.toml .
182
- # COPY +gen-bindings/hermes.rs src/hermes.rs
183
- # COPY auth-module/lib/*.json .
184
- # DO rust-ci+CARGO --args "build --target wasm32-wasip2 --release" --output="wasm32-wasip2/release/auth_module.wasm"
185
- # SAVE ARTIFACT target/wasm32-wasip2/release/auth_module.wasm AS LOCAL auth-module/lib/auth_module.wasm
186
- #
187
- # build-database-module:
188
- # DO rust-ci+SETUP
189
- # WORKDIR /app
190
- # COPY --keep-ts --dir database-module/src .
191
- # COPY database-module/Cargo.toml .
192
- # COPY +gen-bindings/hermes.rs src/hermes.rs
193
- # COPY database-module/lib/*.json .
194
- # DO rust-ci+CARGO --args "build --target wasm32-wasip2 --release" --output="wasm32-wasip2/release/database_module.wasm"
195
- # SAVE ARTIFACT target/wasm32-wasip2/release/database_module.wasm AS LOCAL database-module/lib/database_module.wasm
196
79
197
80
# Complete Multi-Module Build Pipeline
198
81
# =====================================
199
82
# Orchestrates the complete build process for all components.
200
83
# This target builds the Hermes engine and all WASM modules in the correct order.
201
- #
202
- # 🏗️ SCALABLE ARCHITECTURE: As modules are added, they're included here for parallel builds
203
- # ⚡ PARALLEL COMPILATION: Multiple modules can build simultaneously for speed
204
- # 🎯 DEPENDENCY MANAGEMENT: Ensures proper build order and shared resource generation
205
- #
206
- # Current Build Order:
207
- # 1. get-local-hermes: Core runtime engine
208
- # 2. build-http-proxy: HTTP proxy WASM module (includes binding generation)
209
- #
210
- # Future Multi-Module Build Order:
211
- # 1. get-local-hermes: Core runtime engine
212
- # 2. Parallel module builds:
213
- # - build-http-proxy: HTTP routing and proxy functionality
214
- # - build-auth-module: Authentication and authorization
215
- # - build-database-module: Database connectivity and ORM
216
- # - build-cache-module: Caching and session management
217
- # - build-notification-module: Email, SMS, push notifications
218
- # - build-analytics-module: Request tracking and metrics
219
- #
220
84
# Use this target for:
221
85
# - Complete rebuilds from clean state
222
86
# - CI/CD pipeline builds
@@ -246,31 +110,6 @@ build-all:
246
110
# Earthly provides reproducible, containerized builds that work consistently across
247
111
# different development environments without requiring local Rust toolchains.
248
112
#
249
- # Multi-Module Application Architecture:
250
- # 🏗️ Applications can contain MULTIPLE WASM modules working together
251
- # 📦 Each module is compiled independently and packaged together
252
- # 🔗 Modules communicate through Hermes runtime interfaces
253
- # 🎯 Currently building: HTTP proxy (first of many planned modules)
254
- #
255
- # Scalable Build System:
256
- # - Each module gets its own build target (e.g., +build-http-proxy, +build-auth-module)
257
- # - Shared binding generation (+gen-bindings) used by all modules
258
- # - Parallel compilation of multiple modules for faster builds
259
- # - Individual module testing and development workflows
260
- #
261
- # Build Architecture:
262
- # 1. Import reusable build components from external sources
263
- # 2. Generate shared WebAssembly Interface Type (WIT) bindings
264
- # 3. Compile each Rust module to WebAssembly (WASM) using wasm32-wasip2 target
265
- # 4. Package all modules together into a single application bundle
266
- #
267
- # Key Benefits:
268
- # - Consistent builds across different machines and CI/CD environments
269
- # - No need to install Rust toolchains locally
270
- # - Automatic dependency management and caching
271
- # - Isolated build environments prevent "works on my machine" issues
272
- # - Modular architecture allows independent development and testing
273
- #
274
113
# Usage Examples:
275
114
# earthly +build-all # Build everything (engine + all modules)
276
115
# earthly +get-local-hermes # Build just the Hermes engine
0 commit comments