1
- # syntax = docker/dockerfile:1
1
+ # syntax = docker/dockerfile:1.7-labs
2
2
3
3
# Docker image for rs-drive-abci
4
4
#
@@ -181,7 +181,6 @@ RUN <<EOS
181
181
echo "export AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" >> /root/env
182
182
# AWS_SECRET_ACCESS_KEY is a secret so we load it using ONBUILD ARG later on
183
183
echo "export SCCACHE_BUCKET=' ${SCCACHE_BUCKET}'" >> /root/env
184
- # echo "export SCCACHE_S3_USE_SSL=true" >> /root/env
185
184
echo "export SCCACHE_S3_KEY_PREFIX=' ${SCCACHE_S3_KEY_PREFIX}/${TARGETARCH}/linux-musl'" >> /root/env
186
185
elif [ -n "${SCCACHE_MEMCACHED}" ]; then
187
186
# memcached
@@ -266,7 +265,7 @@ RUN set -ex; \
266
265
DOWNLOAD_URL="https://github.com/cargo-bins/cargo-binstall/releases/download/v${BINSTALL_VERSION}/cargo-binstall-${CARGO_BINSTALL_ARCH}.tgz"; \
267
266
# Download and extract the cargo-binstall binary
268
267
curl -A "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0" -L --proto ' =https' --tlsv1.2 -sSf "$DOWNLOAD_URL" | tar -xvzf -; \
269
- ./cargo-binstall -y --force cargo-binstall; \
268
+ ./cargo-binstall -y --force cargo-binstall@${BINSTALL_VERSION} ; \
270
269
rm ./cargo-binstall; \
271
270
source $HOME/.cargo/env; \
272
271
cargo binstall -V
@@ -285,14 +284,46 @@ RUN source $HOME/.cargo/env; \
285
284
FROM deps AS build-planner
286
285
287
286
WORKDIR /platform
288
- COPY . .
289
287
290
- RUN source $HOME/.cargo/env && \
288
+ COPY --parents \
289
+ Cargo.lock \
290
+ Cargo.toml \
291
+ rust-toolchain.toml \
292
+ .cargo \
293
+ packages/dapi-grpc \
294
+ packages/rs-dapi-grpc-macros \
295
+ packages/rs-dpp \
296
+ packages/rs-drive \
297
+ packages/rs-platform-value \
298
+ packages/rs-platform-serialization \
299
+ packages/rs-platform-serialization-derive \
300
+ packages/rs-platform-version \
301
+ packages/rs-platform-versioning \
302
+ packages/rs-platform-value-convertible \
303
+ packages/rs-drive-abci \
304
+ packages/dashpay-contract \
305
+ packages/withdrawals-contract \
306
+ packages/masternode-reward-shares-contract \
307
+ packages/feature-flags-contract \
308
+ packages/dpns-contract \
309
+ packages/data-contracts \
310
+ packages/strategy-tests \
311
+ packages/simple-signer \
312
+ packages/rs-json-schema-compatibility-validator \
313
+ # TODO: We don' t need those. Maybe dynamically remove them from workspace or move outside of monorepo?
314
+ packages/rs-drive-proof-verifier \
315
+ packages/wasm-dpp \
316
+ packages/rs-dapi-client \
317
+ packages/rs-sdk \
318
+ packages/check-features \
319
+ /platform/
320
+
321
+ RUN if [[ "${CARGO_BUILD_PROFILE}" == "release" ]] ; then \
322
+ export RELEASE="--release" ; \
323
+ fi && \
324
+ source $HOME/.cargo/env && \
291
325
source /root/env && \
292
- cargo chef prepare --recipe-path recipe.json
293
-
294
- # Workaround: as we cache dapi-grpc, its build.rs is not rerun, so we need to touch it
295
- RUN touch /platform/packages/dapi-grpc/build.rs
326
+ cargo chef prepare $RELEASE --recipe-path recipe.json
296
327
297
328
#
298
329
# STAGE: BUILD RS-DRIVE-ABCI
@@ -304,13 +335,12 @@ SHELL ["/bin/bash", "-o", "pipefail","-e", "-x", "-c"]
304
335
305
336
WORKDIR /platform
306
337
307
- COPY --from=build-planner /platform/recipe.json recipe.json
338
+ COPY --from=build-planner /platform/recipe.json /platform/.cargo /platform/
308
339
309
340
# Build dependencies - this is the caching Docker layer!
310
341
RUN --mount=type=cache,sharing=shared,id=cargo_registry_index,target=${CARGO_HOME}/registry/index \
311
342
--mount=type=cache,sharing=shared,id=cargo_registry_cache,target=${CARGO_HOME}/registry/cache \
312
343
--mount=type=cache,sharing=shared,id=cargo_git,target=${CARGO_HOME}/git/db \
313
- #--mount=type=cache,sharing=shared,id=target_${TARGETARCH},target=/platform/target \
314
344
set -ex; \
315
345
if [[ "${CARGO_BUILD_PROFILE}" == "release" ]] ; then \
316
346
mv .cargo/config-release.toml .cargo/config.toml; \
@@ -327,7 +357,40 @@ RUN --mount=type=cache,sharing=shared,id=cargo_registry_index,target=${CARGO_HOM
327
357
--locked && \
328
358
if [[ -x /usr/bin/sccache ]]; then sccache --show-stats; fi
329
359
330
- COPY . .
360
+ COPY --parents \
361
+ Cargo.lock \
362
+ Cargo.toml \
363
+ rust-toolchain.toml \
364
+ .cargo \
365
+ packages/dapi-grpc \
366
+ packages/rs-dapi-grpc-macros \
367
+ packages/rs-dpp \
368
+ packages/rs-drive \
369
+ packages/rs-platform-value \
370
+ packages/rs-platform-serialization \
371
+ packages/rs-platform-serialization-derive \
372
+ packages/rs-platform-version \
373
+ packages/rs-platform-versioning \
374
+ packages/rs-platform-value-convertible \
375
+ packages/rs-drive-abci \
376
+ packages/dashpay-contract \
377
+ packages/withdrawals-contract \
378
+ packages/masternode-reward-shares-contract \
379
+ packages/feature-flags-contract \
380
+ packages/dpns-contract \
381
+ packages/data-contracts \
382
+ packages/strategy-tests \
383
+ # These packages are part of workspace and must be here otherwise it builds from scratch
384
+ # See todo below
385
+ packages/simple-signer \
386
+ packages/rs-json-schema-compatibility-validator \
387
+ # TODO: We don't need those. Maybe dynamically remove them from workspace or move outside of monorepo?
388
+ packages/rs-drive-proof-verifier \
389
+ packages/wasm-dpp \
390
+ packages/rs-dapi-client \
391
+ packages/rs-sdk \
392
+ packages/check-features \
393
+ /platform/
331
394
332
395
RUN mkdir /artifacts
333
396
@@ -345,15 +408,17 @@ RUN --mount=type=cache,sharing=shared,id=cargo_registry_index,target=${CARGO_HOM
345
408
export FEATURES_FLAG="--features=console,grovedbg" ; \
346
409
export OUT_DIRECTORY=debug ; \
347
410
fi && \
411
+ # Workaround: as we cache dapi-grpc, its build.rs is not rerun, so we need to touch it
412
+ echo "// $(date) " >> /platform/packages/dapi-grpc/build.rs && \
348
413
cargo build \
349
414
--profile "${CARGO_BUILD_PROFILE}" \
350
415
--package drive-abci \
351
416
${FEATURES_FLAG} \
352
417
--locked && \
353
- cp /platform/ target/${OUT_DIRECTORY}/drive-abci /artifacts/ && \
354
- # Remove target directory to save space
355
- rm -rf target && \
356
- if [[ -x /usr/bin/sccache ]]; then sccache --show-stats; fi
418
+ cp target/${OUT_DIRECTORY}/drive-abci /artifacts/ && \
419
+ if [[ -x /usr/bin/sccache ]]; then sccache --show-stats; fi && \
420
+ # Remove /platform to reduce layer size
421
+ rm -rf /platform
357
422
358
423
#
359
424
# STAGE: BUILD JAVASCRIPT INTERMEDIATE IMAGE
@@ -378,7 +443,42 @@ RUN --mount=type=cache,sharing=shared,id=cargo_registry_index,target=${CARGO_HOM
378
443
--locked && \
379
444
if [[ -x /usr/bin/sccache ]]; then sccache --show-stats; fi
380
445
381
- COPY . .
446
+
447
+ # Rust deps
448
+ COPY --parents \
449
+ Cargo.lock \
450
+ Cargo.toml \
451
+ rust-toolchain.toml \
452
+ .cargo \
453
+ packages/rs-dpp \
454
+ packages/rs-platform-value \
455
+ packages/rs-platform-serialization \
456
+ packages/rs-platform-serialization-derive \
457
+ packages/rs-platform-version \
458
+ packages/rs-platform-versioning \
459
+ packages/rs-platform-value-convertible \
460
+ packages/rs-json-schema-compatibility-validator \
461
+ # Common
462
+ packages/wasm-dpp \
463
+ packages/dashpay-contract \
464
+ packages/withdrawals-contract \
465
+ packages/masternode-reward-shares-contract \
466
+ packages/feature-flags-contract \
467
+ packages/dpns-contract \
468
+ packages/data-contracts \
469
+ packages/dapi-grpc \
470
+ # JS deps
471
+ .yarn \
472
+ .pnp* \
473
+ .yarnrc.yml \
474
+ yarn.lock \
475
+ package.json \
476
+ packages/js-grpc-common \
477
+ packages/js-dapi-client \
478
+ packages/wallet-lib \
479
+ packages/js-dash-sdk \
480
+ packages/dash-spv \
481
+ /platform/
382
482
383
483
RUN --mount=type=cache,sharing=shared,id=cargo_registry_index,target=${CARGO_HOME}/registry/index \
384
484
--mount=type=cache,sharing=shared,id=cargo_registry_cache,target=${CARGO_HOME}/registry/cache \
@@ -391,9 +491,9 @@ RUN --mount=type=cache,sharing=shared,id=cargo_registry_index,target=${CARGO_HOM
391
491
cp -R /platform/.yarn/unplugged /tmp/ && \
392
492
export SKIP_GRPC_PROTO_BUILD=1 && \
393
493
yarn build && \
394
- # Remove target directory to save space
395
- rm -rf target && \
396
- if [[ -x /usr/bin/sccache ]]; then sccache --show-stats; fi
494
+ if [[ -x /usr/bin/sccache ]]; then sccache --show-stats; fi && \
495
+ # Remove target directory and rust packages to save space
496
+ rm -rf target packages/rs-*
397
497
398
498
#
399
499
# STAGE: FINAL DRIVE-ABCI IMAGE
@@ -413,7 +513,7 @@ RUN mkdir -p /var/log/dash \
413
513
${REJECTIONS_PATH}
414
514
415
515
COPY --from=build-drive-abci /artifacts/drive-abci /usr/bin/drive-abci
416
- COPY --from=build-drive-abci /platform/ packages/rs-drive-abci/.env.mainnet /var/lib/dash/rs-drive-abci/.env
516
+ COPY packages/rs-drive-abci/.env.mainnet /var/lib/dash/rs-drive-abci/.env
417
517
418
518
# Create a volume
419
519
VOLUME /var/lib/dash/rs-drive-abci/db
@@ -450,6 +550,9 @@ EXPOSE 29090
450
550
#
451
551
FROM build-js AS build-dashmate-helper
452
552
553
+ # Copy dashmate package
554
+ COPY packages/dashmate packages/dashmate
555
+
453
556
# Install Test Suite specific dependencies using previous
454
557
# node_modules directory to reuse built binaries
455
558
RUN yarn workspaces focus --production dashmate
@@ -494,6 +597,8 @@ ENTRYPOINT ["/platform/packages/dashmate/docker/entrypoint.sh"]
494
597
#
495
598
FROM build-js AS build-test-suite
496
599
600
+ COPY packages/platform-test-suite packages/platform-test-suite
601
+
497
602
# Install Test Suite specific dependencies using previous
498
603
# node_modules directory to reuse built binaries
499
604
RUN yarn workspaces focus --production @dashevo/platform-test-suite
@@ -511,38 +616,6 @@ LABEL description="Dash Platform test suite"
511
616
WORKDIR /platform
512
617
513
618
COPY --from=build-test-suite /platform /platform
514
-
515
-
516
- # Copy yarn and Cargo files
517
- COPY --from=build-test-suite /platform/.yarn /platform/.yarn
518
- COPY --from=build-test-suite /platform/package.json /platform/yarn.lock \
519
- /platform/.yarnrc.yml /platform/.pnp.* /platform/Cargo.lock /platform/rust-toolchain.toml ./
520
- # Use Cargo.toml.template instead of Cargo.toml from project root to avoid copying unnecessary Rust packages
521
- COPY --from=build-test-suite /platform/packages/platform-test-suite/Cargo.toml.template ./Cargo.toml
522
-
523
- # Copy only necessary packages from monorepo
524
- COPY --from=build-test-suite /platform/packages/platform-test-suite packages/platform-test-suite
525
- COPY --from=build-test-suite /platform/packages/dashpay-contract packages/dashpay-contract
526
- COPY --from=build-test-suite /platform/packages/wallet-lib packages/wallet-lib
527
- COPY --from=build-test-suite /platform/packages/js-dash-sdk packages/js-dash-sdk
528
- COPY --from=build-test-suite /platform/packages/js-dapi-client packages/js-dapi-client
529
- COPY --from=build-test-suite /platform/packages/js-grpc-common packages/js-grpc-common
530
- COPY --from=build-test-suite /platform/packages/dapi-grpc packages/dapi-grpc
531
- COPY --from=build-test-suite /platform/packages/dash-spv packages/dash-spv
532
- COPY --from=build-test-suite /platform/packages/withdrawals-contract packages/withdrawals-contract
533
- COPY --from=build-test-suite /platform/packages/rs-platform-value packages/rs-platform-value
534
- COPY --from=build-test-suite /platform/packages/masternode-reward-shares-contract packages/masternode-reward-shares-contract
535
- COPY --from=build-test-suite /platform/packages/feature-flags-contract packages/feature-flags-contract
536
- COPY --from=build-test-suite /platform/packages/dpns-contract packages/dpns-contract
537
- COPY --from=build-test-suite /platform/packages/data-contracts packages/data-contracts
538
- COPY --from=build-test-suite /platform/packages/rs-platform-serialization packages/rs-platform-serialization
539
- COPY --from=build-test-suite /platform/packages/rs-platform-serialization-derive packages/rs-platform-serialization-derive
540
- COPY --from=build-test-suite /platform/packages/rs-platform-version packages/rs-platform-version
541
- COPY --from=build-test-suite /platform/packages/rs-platform-versioning packages/rs-platform-versioning
542
- COPY --from=build-test-suite /platform/packages/rs-platform-value-convertible packages/rs-platform-value-convertible
543
- COPY --from=build-test-suite /platform/packages/rs-dpp packages/rs-dpp
544
- COPY --from=build-test-suite /platform/packages/wasm-dpp packages/wasm-dpp
545
-
546
619
COPY --from=build-test-suite /platform/packages/platform-test-suite/.env.example /platform/packages/platform-test-suite/.env
547
620
548
621
EXPOSE 2500 2501 2510
@@ -554,6 +627,8 @@ ENTRYPOINT ["/platform/packages/platform-test-suite/bin/test.sh"]
554
627
#
555
628
FROM build-js AS build-dapi
556
629
630
+ COPY packages/dapi packages/dapi
631
+
557
632
# Install Test Suite specific dependencies using previous
558
633
# node_modules directory to reuse built binaries
559
634
RUN yarn workspaces focus --production @dashevo/dapi
@@ -579,7 +654,6 @@ COPY --from=build-dapi /platform/packages/dapi /platform/packages/dapi
579
654
COPY --from=build-dapi /platform/packages/dapi-grpc /platform/packages/dapi-grpc
580
655
COPY --from=build-dapi /platform/packages/js-grpc-common /platform/packages/js-grpc-common
581
656
COPY --from=build-dapi /platform/packages/wasm-dpp /platform/packages/wasm-dpp
582
- COPY --from=build-dapi /platform/packages/js-dapi-client /platform/packages/js-dapi-client
583
657
584
658
RUN cp /platform/packages/dapi/.env.example /platform/packages/dapi/.env
585
659
0 commit comments