-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile
More file actions
754 lines (585 loc) · 31.1 KB
/
Dockerfile
File metadata and controls
754 lines (585 loc) · 31.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
# syntax=docker/dockerfile:1
# ==============================================================================
# Base image with Rust toolchain (Alpine - more reliable than Debian)
# ==============================================================================
FROM alpine:3.22 AS rust-base
# Install system dependencies
# - protoc/protobuf-dev: Required for prost-build (proto compilation in build.rs)
# - musl-dev: Required for linking Rust binaries on Alpine
RUN apk add --no-cache \
protobuf-dev \
protoc \
musl-dev \
make \
gcc \
curl \
ca-certificates
# Install rustup into system-wide dirs so later stages can cache/copy them
ENV CARGO_HOME=/usr/local/cargo \
RUSTUP_HOME=/usr/local/rustup \
PATH=/usr/local/cargo/bin:$PATH
# Install rustup with no default toolchain; the toolchain file will drive installs
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
sh -s -- -y --profile minimal --default-toolchain none
WORKDIR /workspace
# Copy rust-toolchain.toml and let rustup configure everything automatically
COPY rust-toolchain.toml ./
# Install toolchain from rust-toolchain.toml (components + targets)
RUN rustup show
# ==============================================================================
# Dependencies layer - cached separately from source code
# ==============================================================================
FROM rust-base AS rust-deps
# Copy only dependency manifests first for better caching
COPY Cargo.toml Cargo.lock ./
COPY confidence-resolver/Cargo.toml ./confidence-resolver/
COPY confidence-cloudflare-resolver/Cargo.toml ./confidence-cloudflare-resolver/
COPY wasm-msg/Cargo.toml ./wasm-msg/
COPY wasm/rust-guest/Cargo.toml ./wasm/rust-guest/
COPY openfeature-provider/java/Cargo.toml ./openfeature-provider/java/
COPY openfeature-provider/js/Cargo.toml ./openfeature-provider/js/
COPY openfeature-provider/go/Cargo.toml ./openfeature-provider/go/
COPY openfeature-provider/rust/Cargo.toml ./openfeature-provider/rust/
COPY openfeature-provider/python/Cargo.toml ./openfeature-provider/python/
# Copy proto files (needed by build.rs)
COPY confidence-resolver/protos ./confidence-resolver/protos/
COPY wasm-msg/proto ./wasm-msg/proto/
COPY wasm/proto ./wasm/proto/
# Copy build.rs files
COPY confidence-resolver/build.rs ./confidence-resolver/
COPY wasm-msg/build.rs ./wasm-msg/
COPY wasm/rust-guest/build.rs ./wasm/rust-guest/
COPY openfeature-provider/rust/build.rs ./openfeature-provider/rust/
COPY openfeature-provider/proto/ ./openfeature-provider/proto/
# Create dummy source files to build dependencies
RUN mkdir -p confidence-resolver/src && \
echo "pub fn dummy() {}" > confidence-resolver/src/lib.rs && \
mkdir -p confidence-cloudflare-resolver/src && \
echo "pub fn dummy() {}" > confidence-cloudflare-resolver/src/lib.rs && \
mkdir -p wasm-msg/src && \
echo "pub fn dummy() {}" > wasm-msg/src/lib.rs && \
mkdir -p wasm/rust-guest/src && \
echo "pub fn dummy() {}" > wasm/rust-guest/src/lib.rs && \
mkdir -p openfeature-provider/rust/src && \
echo "pub fn dummy() {}" > openfeature-provider/rust/src/lib.rs
# Build dependencies (this layer will be cached)
RUN cargo build -p confidence_resolver --release
# Build test dependencies including dev-dependencies (this layer will be cached)
RUN cargo test -p confidence_resolver --lib --no-run --release
# Build WASM dependencies (this layer will be cached)
RUN cargo build -p rust-guest --target wasm32-unknown-unknown --profile wasm
# Build confidence-cloudflare-resolver dependencies (this layer will be cached)
RUN RUSTFLAGS='--cfg getrandom_backend="wasm_js"' cargo build -p confidence-cloudflare-resolver --target wasm32-unknown-unknown --release
# ==============================================================================
# Test & Lint Base - Copy source for testing/linting (native builds)
# ==============================================================================
FROM rust-base AS rust-test-base
# Copy the dependency cache from deps stage
COPY --from=rust-deps /usr/local/cargo /usr/local/cargo
COPY --from=rust-deps /workspace/target /workspace/target
# Copy all Rust source files (workspace requires all members present)
COPY Cargo.toml Cargo.lock ./
COPY confidence-resolver/ ./confidence-resolver/
COPY confidence-cloudflare-resolver/ ./confidence-cloudflare-resolver/
COPY wasm-msg/ ./wasm-msg/
COPY wasm/rust-guest/ ./wasm/rust-guest/
COPY wasm/proto/ ./wasm/proto/
COPY openfeature-provider/java/Cargo.toml ./openfeature-provider/java/
COPY openfeature-provider/js/Cargo.toml ./openfeature-provider/js/
COPY openfeature-provider/go/Cargo.toml ./openfeature-provider/go/
COPY openfeature-provider/proto/ ./openfeature-provider/proto/
COPY openfeature-provider/rust/ ./openfeature-provider/rust/
COPY openfeature-provider/python/Cargo.toml ./openfeature-provider/python/
# Touch files to ensure rebuild (dependencies are cached)
RUN find . -type f -name "*.rs" -exec touch {} +
ENV IN_DOCKER_BUILD=1
# ==============================================================================
# Build confidence-resolver (test + lint derive from this to reuse artifacts)
# ==============================================================================
FROM rust-test-base AS confidence-resolver.build
WORKDIR /workspace/confidence-resolver
RUN cargo build --release --lib
# ==============================================================================
# Test confidence-resolver
# ==============================================================================
FROM confidence-resolver.build AS confidence-resolver.test
WORKDIR /workspace/confidence-resolver
RUN make test
# ==============================================================================
# Build wasm-msg (test + lint derive from this to reuse artifacts)
# ==============================================================================
FROM rust-test-base AS wasm-msg.build
WORKDIR /workspace/wasm-msg
RUN cargo build --release --lib
# ==============================================================================
# Test wasm-msg (when tests exist)
# ==============================================================================
FROM wasm-msg.build AS wasm-msg.test
WORKDIR /workspace/wasm-msg
RUN make test
# ==============================================================================
# Lint confidence-resolver
# ==============================================================================
FROM confidence-resolver.build AS confidence-resolver.lint
WORKDIR /workspace/confidence-resolver
RUN make lint
# ==============================================================================
# Lint wasm-msg
# ==============================================================================
FROM wasm-msg.build AS wasm-msg.lint
WORKDIR /workspace/wasm-msg
RUN make lint
# ==============================================================================
# WASM Dependencies - Build WASM-specific dependencies
# ==============================================================================
FROM rust-base AS wasm-deps
# Copy the dependency cache from deps stage
COPY --from=rust-deps /usr/local/cargo /usr/local/cargo
COPY --from=rust-deps /workspace/target /workspace/target
# Copy only Rust-related source files (not Node.js/Python/Java)
COPY Cargo.toml Cargo.lock ./
COPY confidence-resolver/ ./confidence-resolver/
COPY confidence-cloudflare-resolver/ ./confidence-cloudflare-resolver/
COPY wasm-msg/ ./wasm-msg/
COPY wasm/rust-guest/ ./wasm/rust-guest/
COPY wasm/proto/ ./wasm/proto/
COPY openfeature-provider/java/Cargo.toml ./openfeature-provider/java/
COPY openfeature-provider/js/Cargo.toml ./openfeature-provider/js/
COPY openfeature-provider/go/Cargo.toml ./openfeature-provider/go/
COPY openfeature-provider/proto/ ./openfeature-provider/proto/
COPY openfeature-provider/rust/ ./openfeature-provider/rust/
COPY openfeature-provider/python/Cargo.toml ./openfeature-provider/python/
# Copy data directory (needed by confidence-cloudflare-resolver include_str! macros)
COPY data/ ./data/
# Touch files to ensure rebuild
RUN find . -type f -name "*.rs" -exec touch {} +
ENV IN_DOCKER_BUILD=1
# ==============================================================================
# Build wasm/rust-guest WASM
# ==============================================================================
FROM wasm-deps AS wasm-rust-guest.build
WORKDIR /workspace/wasm/rust-guest
RUN make build
# Change back to workspace root to find the target directory
WORKDIR /workspace
# Verify build artifact
RUN ls -lh target/wasm32-unknown-unknown/wasm/rust_guest.wasm && \
echo "WASM size: $(du -h target/wasm32-unknown-unknown/wasm/rust_guest.wasm | cut -f1)"
# ==============================================================================
# Lint wasm/rust-guest (WASM target)
# ==============================================================================
FROM wasm-deps AS wasm-rust-guest.lint
WORKDIR /workspace/wasm/rust-guest
RUN make lint
# ==============================================================================
# Extract wasm/rust-guest WASM artifact
# ==============================================================================
FROM scratch AS wasm-rust-guest.artifact
COPY --from=wasm-rust-guest.build /workspace/target/wasm32-unknown-unknown/wasm/rust_guest.wasm /confidence_resolver.wasm
# ==============================================================================
# Build confidence-cloudflare-resolver (WASM target)
# ==============================================================================
FROM wasm-deps AS confidence-cloudflare-resolver.build
WORKDIR /workspace/confidence-cloudflare-resolver
RUN make build
# ==============================================================================
# Lint confidence-cloudflare-resolver (WASM target)
# ==============================================================================
FROM confidence-cloudflare-resolver.build AS confidence-cloudflare-resolver.lint
WORKDIR /workspace/confidence-cloudflare-resolver
RUN make lint
# ==============================================================================
# CloudFlare Deployer - Runtime image for deploying to CloudFlare Workers
# ==============================================================================
FROM confidence-cloudflare-resolver.build AS confidence-cloudflare-resolver.deployer
# Install Node.js, npm, jq, git, and bash for deployment
RUN apk add --no-cache nodejs npm jq git bash
# Install Wrangler CLI
RUN npm install -g wrangler@latest
# Install worker-build (Rust WASM build tool used by Wrangler)
ARG WORKER_BUILD_VERSION="0.1.11"
RUN cargo install worker-build --locked --version ${WORKER_BUILD_VERSION}
# Install wasm-bindgen-cli (required by worker-build, must match version in Cargo.lock)
RUN cargo install wasm-bindgen-cli --version 0.2.100
# Optionally pass the commit SHA at build time
ARG COMMIT_SHA=""
ENV COMMIT_SHA=${COMMIT_SHA}
# Return to workspace root
WORKDIR /workspace
# Clean sample/runtime data to avoid leaking into image
RUN rm -rf data/*
# Ensure deploy script is executable
RUN chmod +x confidence-cloudflare-resolver/deployer/script.sh
# Default command runs the deployer script
CMD ["./confidence-cloudflare-resolver/deployer/script.sh"]
# ==============================================================================
# OpenFeature Provider (TypeScript) - Build and test
# ==============================================================================
FROM node:20-alpine AS openfeature-provider-js-base
# Install protoc for proto generation
RUN apk add --no-cache protobuf-dev protoc make
WORKDIR /app
# Enable Corepack for Yarn
RUN corepack enable
# Copy package files for dependency caching
COPY \
openfeature-provider/js/Makefile \
openfeature-provider/js/package.json \
openfeature-provider/js/yarn.lock \
openfeature-provider/js/.yarnrc.yml \
openfeature-provider/js/README.md \
openfeature-provider/js/CHANGELOG.md \
openfeature-provider/js/LICENSE \
./
COPY openfeature-provider/js/proto ./proto
# Copy proto files needed for proto generation
COPY openfeature-provider/proto ../../../openfeature-provider/proto
# Install dependencies (this layer will be cached)
ENV IN_DOCKER_BUILD=1
RUN make install
# Copy source and config
COPY openfeature-provider/js/src ./src/
COPY openfeature-provider/js/tsconfig.json openfeature-provider/js/tsdown.config.ts openfeature-provider/js/vitest.config.ts ./
COPY openfeature-provider/js/Makefile ./
# Copy WASM module
COPY --from=wasm-rust-guest.artifact /confidence_resolver.wasm ../../../wasm/confidence_resolver.wasm
# ==============================================================================
# Test OpenFeature Provider
# ==============================================================================
FROM openfeature-provider-js-base AS openfeature-provider-js.test
# Copy files needed for testing
COPY wasm/resolver_state.pb ../../../wasm/resolver_state.pb
COPY openfeature-provider/js/prettier.config.cjs ./
COPY openfeature-provider/js/.prettierignore ./
RUN make test
# ==============================================================================
# E2E Test OpenFeature Provider (requires credentials)
# ==============================================================================
FROM openfeature-provider-js.test AS openfeature-provider-js.test_e2e
# Run e2e tests with secrets mounted as .env.test file
RUN make test-e2e
# ==============================================================================
# Build OpenFeature Provider
# ==============================================================================
FROM openfeature-provider-js-base AS openfeature-provider-js.build
RUN make build
# Verify no bundle splitting occurred
RUN set -e; \
echo "Verifying no bundle splitting in JS artifacts..."; \
UNEXPECTED_FILES=$(find dist -name '*.js' ! -name 'index.node.js' ! -name 'index.inlined.js' ! -name 'index.fetch.js' ! -name 'server.js' ! -name 'client.js' | head -10); \
if [ -n "$UNEXPECTED_FILES" ]; then \
echo ""; \
echo "❌ ERROR: Bundle splitting detected!"; \
echo ""; \
echo "Found unexpected JavaScript files in dist/:"; \
echo "$UNEXPECTED_FILES"; \
echo ""; \
echo "Only expected entry point files should be present."; \
echo "Check tsdown.config.ts configuration to prevent code splitting."; \
echo ""; \
exit 1; \
fi; \
echo "✅ No bundle splitting detected - only expected files present"
# ==============================================================================
# Pack OpenFeature Provider (JS) - Create tarball for publishing
# ==============================================================================
FROM openfeature-provider-js.build AS openfeature-provider-js.pack
RUN yarn pack
# ==============================================================================
# Extract OpenFeature Provider (JS) package artifact
# ==============================================================================
FROM scratch AS openfeature-provider-js.artifact
COPY --from=openfeature-provider-js.pack /app/package.tgz /package.tgz
# ==============================================================================
# OpenFeature Provider (Go) - Build and test
# ==============================================================================
FROM golang:1.24-alpine AS openfeature-provider-go-base
# Install make (needed for Makefile targets)
RUN apk add --no-cache make
WORKDIR /app
# Copy Makefile (at top level of go provider)
COPY openfeature-provider/go/Makefile ./
# Copy go.mod for dependency caching from confidence/ subdirectory
COPY openfeature-provider/go/go.mod openfeature-provider/go/go.sum ./
# Download Go dependencies (this layer will be cached)
RUN go mod download
# Copy source code
COPY openfeature-provider/go/confidence/ ./confidence/
# Set environment variable
ENV IN_DOCKER_BUILD=1
# ==============================================================================
# Validate WASM sync for Go Provider
# ==============================================================================
FROM alpine:3.22 AS openfeature-provider-go.validate-wasm
# Install diffutils for cmp command
RUN apk add --no-cache diffutils
# Copy built WASM from artifact
COPY --from=wasm-rust-guest.artifact /confidence_resolver.wasm /built/confidence_resolver.wasm
# Copy committed WASM from source
COPY openfeature-provider/go/confidence/internal/local_resolver/assets/confidence_resolver.wasm /committed/confidence_resolver.wasm
# Compare files
RUN set -e; \
echo "Validating WASM sync for Go provider..."; \
if ! cmp -s /built/confidence_resolver.wasm /committed/confidence_resolver.wasm; then \
echo ""; \
echo "❌ ERROR: WASM files are out of sync!"; \
echo ""; \
echo "The WASM file in openfeature-provider/go/confidence/wasm/ doesn't match the built version."; \
echo ""; \
echo "To fix (using Docker to ensure correct dependencies):"; \
echo " docker build --target wasm-rust-guest.artifact --output type=local,dest=. ."; \
echo " cp confidence_resolver.wasm openfeature-provider/go/confidence/wasm/"; \
echo " git add openfeature-provider/go/confidence/wasm/confidence_resolver.wasm"; \
echo " git commit -m 'chore: sync WASM module for Go provider'"; \
echo ""; \
echo "Or use the Makefile target:"; \
echo " make sync-wasm-go"; \
echo ""; \
exit 1; \
fi; \
echo "✅ WASM files are in sync"
# ==============================================================================
# Build OpenFeature Provider (Go) (test + lint derive from this)
# ==============================================================================
FROM openfeature-provider-go-base AS openfeature-provider-go.build
RUN make build
# ==============================================================================
# Test OpenFeature Provider (Go)
# ==============================================================================
FROM openfeature-provider-go.build AS openfeature-provider-go.test
RUN make test
# ==============================================================================
# Lint OpenFeature Provider (Go)
# ==============================================================================
FROM openfeature-provider-go.build AS openfeature-provider-go.lint
RUN make lint
# ==============================================================================
# OpenFeature Provider (Ruby) - Build and test
# ==============================================================================
FROM ruby:3.3-alpine AS openfeature-provider-ruby-base
# Install build dependencies
RUN apk add --no-cache make git build-base openssl-dev
WORKDIR /app
# Copy Gemfile for dependency caching
COPY openfeature-provider/ruby/Gemfile ./
COPY openfeature-provider/ruby/confidence-openfeature-provider.gemspec ./
COPY openfeature-provider/ruby/Makefile ./
# Copy lib directory (needed by gemspec to read version)
COPY openfeature-provider/ruby/lib ./lib/
# Install dependencies (this layer will be cached)
ENV IN_DOCKER_BUILD=1
RUN make install
# Copy remaining source code
COPY openfeature-provider/ruby/spec ./spec/
COPY openfeature-provider/ruby/Rakefile ./
# ==============================================================================
# Test OpenFeature Provider (Ruby)
# ==============================================================================
FROM openfeature-provider-ruby-base AS openfeature-provider-ruby.test
RUN make test
# ==============================================================================
# Lint OpenFeature Provider (Ruby)
# ==============================================================================
FROM openfeature-provider-ruby-base AS openfeature-provider-ruby.lint
RUN make lint
# ==============================================================================
# Build OpenFeature Provider (Ruby)
# ==============================================================================
FROM openfeature-provider-ruby-base AS openfeature-provider-ruby.build
RUN make build
# ==============================================================================
# Extract OpenFeature Provider (Ruby) gem artifact
# ==============================================================================
FROM scratch AS openfeature-provider-ruby.artifact
COPY --from=openfeature-provider-ruby.build /app/pkg/*.gem /
# ==============================================================================
# Publish OpenFeature Provider (Ruby) to RubyGems
# ==============================================================================
FROM openfeature-provider-ruby.build AS openfeature-provider-ruby.publish
RUN --mount=type=secret,id=rubygem_api_key \
export GEM_HOST_API_KEY=$(cat /run/secrets/rubygem_api_key) && \
gem push pkg/*.gem
# ==============================================================================
# OpenFeature Provider (Python) - Build and test
# ==============================================================================
FROM python:3.11-slim AS openfeature-provider-python-base
# Install protobuf and build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
protobuf-compiler \
libprotobuf-dev \
make \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy Makefile and pyproject.toml for dependency caching
COPY openfeature-provider/python/Makefile ./
COPY openfeature-provider/python/pyproject.toml ./
COPY openfeature-provider/python/README.md ./
# Copy proto files (needed for proto generation)
COPY openfeature-provider/proto ../proto/
# Copy source code
COPY openfeature-provider/python/src ./src/
COPY openfeature-provider/python/tests ./tests/
# Copy WASM module into resources
COPY --from=wasm-rust-guest.artifact /confidence_resolver.wasm ./resources/wasm/confidence_resolver.wasm
# Copy test data fixtures (needed by tests)
# conftest.py expects data at ../../data relative to python dir
COPY data/ ../../data/
# Set environment variable
ENV IN_DOCKER_BUILD=1
# Install dependencies
RUN make install
# ==============================================================================
# Test OpenFeature Provider (Python)
# ==============================================================================
FROM openfeature-provider-python-base AS openfeature-provider-python.test
RUN make test
# ==============================================================================
# E2E Test OpenFeature Provider (Python) (requires credentials)
# ==============================================================================
FROM openfeature-provider-python.test AS openfeature-provider-python.test_e2e
RUN make test-e2e
# ==============================================================================
# Lint OpenFeature Provider (Python)
# ==============================================================================
FROM openfeature-provider-python-base AS openfeature-provider-python.lint
RUN make lint
# ==============================================================================
# Build OpenFeature Provider (Python)
# ==============================================================================
FROM openfeature-provider-python-base AS openfeature-provider-python.build
RUN make build
# ==============================================================================
# Extract OpenFeature Provider (Python) package artifact
# ==============================================================================
FROM scratch AS openfeature-provider-python.artifact
COPY --from=openfeature-provider-python.build /app/dist/*.whl /
COPY --from=openfeature-provider-python.build /app/dist/*.tar.gz /
# ==============================================================================
# OpenFeature Provider (Rust) - Build (test + lint derive from this)
# ==============================================================================
FROM rust-test-base AS openfeature-provider-rust.build
WORKDIR /workspace/openfeature-provider/rust
RUN make build
# ==============================================================================
# OpenFeature Provider (Rust) - Test
# ==============================================================================
FROM openfeature-provider-rust.build AS openfeature-provider-rust.test
WORKDIR /workspace/openfeature-provider/rust
RUN make test
# ==============================================================================
# OpenFeature Provider (Rust) - E2E Test
# ==============================================================================
FROM openfeature-provider-rust.build AS openfeature-provider-rust.test_e2e
WORKDIR /workspace/openfeature-provider/rust
RUN make test-e2e
# ==============================================================================
# OpenFeature Provider (Rust) - Lint
# ==============================================================================
FROM openfeature-provider-rust.build AS openfeature-provider-rust.lint
WORKDIR /workspace/openfeature-provider/rust
RUN make lint
# ==============================================================================
# Publish confidence-resolver to crates.io
# ==============================================================================
FROM openfeature-provider-rust.build AS confidence-resolver.publish
WORKDIR /workspace/confidence-resolver
RUN --mount=type=secret,id=crates_io_token \
cargo login $(cat /run/secrets/crates_io_token) && \
cargo publish
# ==============================================================================
# Publish OpenFeature Provider (Rust) to crates.io
# ==============================================================================
FROM openfeature-provider-rust.build AS openfeature-provider-rust.publish
WORKDIR /workspace/openfeature-provider/rust
# Copy shared proto files into crate directory for cargo publish tarball verification
RUN cp -r ../proto proto
RUN --mount=type=secret,id=crates_io_token \
cargo login $(cat /run/secrets/crates_io_token) && \
cargo publish
# ==============================================================================
# OpenFeature Provider (Java) - Build and test
# ==============================================================================
FROM eclipse-temurin:17-jdk AS openfeature-provider-java-base
# Install Maven and protobuf (Debian-based for glibc compatibility)
RUN apt-get update && apt-get install -y \
maven \
protobuf-compiler \
make \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy pom.xml for dependency caching
COPY openfeature-provider/java/pom.xml ./
COPY openfeature-provider/java/Makefile ./
# Download dependencies (this layer will be cached)
RUN mvn dependency:go-offline -q || true
# Copy proto files (needed for protobuf generation)
COPY openfeature-provider/proto ../proto/
# Copy source code
COPY openfeature-provider/java/src ./src/
# Copy WASM module into resources
COPY --from=wasm-rust-guest.artifact /confidence_resolver.wasm ../../../wasm/confidence_resolver.wasm
# Set environment variable
ENV IN_DOCKER_BUILD=1
# ==============================================================================
# Build OpenFeature Provider (Java) (test + lint derive from this)
# ==============================================================================
FROM openfeature-provider-java-base AS openfeature-provider-java.build
RUN make build
# ==============================================================================
# Test OpenFeature Provider (Java)
# ==============================================================================
FROM openfeature-provider-java.build AS openfeature-provider-java.test
RUN make test
# ==============================================================================
# E2E Test OpenFeature Provider (Java) (requires credentials)
# ==============================================================================
FROM openfeature-provider-java.test AS openfeature-provider-java.test_e2e
# Run e2e tests with secrets mounted as .env.test file
RUN make test-e2e
# ==============================================================================
# Publish OpenFeature Provider (Java) to Maven Central
# ==============================================================================
FROM openfeature-provider-java.build AS openfeature-provider-java.publish
RUN --mount=type=secret,id=gpg_private_key \
gpg --batch --import /run/secrets/gpg_private_key
RUN --mount=type=secret,id=maven_settings \
--mount=type=secret,id=gpg_pass,env=MAVEN_GPG_PASSPHRASE \
mvn -q -s /run/secrets/maven_settings --batch-mode -DskipTests deploy
# ==============================================================================
# All - Build and validate everything (default target)
# ==============================================================================
FROM scratch AS all
# Copy build artifacts (forces build stages to execute)
COPY --from=wasm-rust-guest.artifact /confidence_resolver.wasm /artifacts/wasm/
# Force test stages to run by copying marker files
COPY --from=confidence-resolver.test /workspace/Cargo.toml /markers/test-resolver
COPY --from=wasm-msg.test /workspace/Cargo.toml /markers/test-wasm-msg
COPY --from=openfeature-provider-js.test /app/package.json /markers/test-openfeature-js
COPY --from=openfeature-provider-js.test_e2e /app/package.json /markers/test-openfeature-js-e2e
COPY --from=openfeature-provider-java.test /app/pom.xml /markers/test-openfeature-java
COPY --from=openfeature-provider-java.test_e2e /app/pom.xml /markers/test-openfeature-java-e2e
COPY --from=openfeature-provider-go.test /app/go.mod /markers/test-openfeature-go
COPY --from=openfeature-provider-ruby.test /app/Gemfile /markers/test-openfeature-ruby
COPY --from=openfeature-provider-python.test /app/pyproject.toml /markers/test-openfeature-python
COPY --from=openfeature-provider-python.test_e2e /app/pyproject.toml /markers/test-openfeature-python-e2e
COPY --from=openfeature-provider-rust.test /workspace/Cargo.toml /markers/test-openfeature-rust
COPY --from=openfeature-provider-rust.test_e2e /workspace/Cargo.toml /markers/test-openfeature-rust-e2e
# Force validation stages to run
COPY --from=openfeature-provider-go.validate-wasm /built/confidence_resolver.wasm /markers/validate-wasm-go
# Force lint stages to run by copying marker files
COPY --from=confidence-resolver.lint /workspace/Cargo.toml /markers/lint-resolver
COPY --from=wasm-msg.lint /workspace/Cargo.toml /markers/lint-wasm-msg
COPY --from=wasm-rust-guest.lint /workspace/Cargo.toml /markers/lint-guest
COPY --from=openfeature-provider-go.lint /app/go.mod /markers/lint-openfeature-go
COPY --from=openfeature-provider-ruby.lint /app/Gemfile /markers/lint-openfeature-ruby
COPY --from=openfeature-provider-python.lint /app/pyproject.toml /markers/lint-openfeature-python
COPY --from=openfeature-provider-rust.lint /workspace/Cargo.toml /markers/lint-openfeature-rust
COPY --from=confidence-cloudflare-resolver.lint /workspace/Cargo.toml /markers/lint-cloudflare
# Force build stages to run
COPY --from=confidence-cloudflare-resolver.build /workspace/Cargo.toml /markers/build-cloudflare
COPY --from=openfeature-provider-js.build /app/dist/index.node.js /artifacts/openfeature-js/
COPY --from=openfeature-provider-java.build /app/target/*.jar /artifacts/openfeature-java/
COPY --from=openfeature-provider-go.build /app/.build.stamp /artifacts/openfeature-go/
COPY --from=openfeature-provider-ruby.build /app/.build.stamp /artifacts/openfeature-ruby/
COPY --from=openfeature-provider-python.build /app/.build.stamp /artifacts/openfeature-python/
COPY --from=openfeature-provider-rust.build /workspace/openfeature-provider/rust/.build.stamp /artifacts/openfeature-rust/