@@ -156,31 +156,32 @@ ENV SCCACHE_S3_KEY_PREFIX=${SCCACHE_S3_KEY_PREFIX}/${TARGETARCH}/linux-musl
156156
157157WORKDIR /platform
158158
159+ # TODO: Use https://github.com/cargo-bins/cargo-binstall
159160# Install wasm-bindgen-cli in the same profile as other components, to sacrifice some performance & disk space to gain
160161# better build caching
161- # RUN --mount=type=cache,sharing=shared,id=cargo_registry_index,target=${CARGO_HOME}/registry/index \
162- # --mount=type=cache,sharing=shared,id=cargo_registry_cache,target=${CARGO_HOME}/registry/cache \
163- # --mount=type=cache,sharing=shared,id=cargo_git,target=${CARGO_HOME}/git/db \
164- # --mount=type=cache,sharing=shared,id=target_${TARGETARCH},target=/platform/target \
165- # export SCCACHE_SERVER_PORT=$((RANDOM+1025)) && \
166- # source $HOME/.cargo/env && \
167- # if [[ -z "${SCCACHE_MEMCACHED}" ]] ; then unset SCCACHE_MEMCACHED ; fi ; \
168- # RUSTFLAGS="-C target-feature=-crt-static" \
169- # CARGO_TARGET_DIR="/platform/target" \
170- # # TODO: Build wasm with build.rs
171- # # Meanwhile if you want to update wasm-bindgen you also need to update version in:
172- # # - packages/wasm-dpp/Cargo.toml
173- # # - packages/wasm-dpp/scripts/build-wasm.sh
174- # cargo install --profile "$CARGO_BUILD_PROFILE" [email protected] [email protected] --locked162+ RUN --mount=type=cache,sharing=shared,id=cargo_registry_index,target=${CARGO_HOME}/registry/index \
163+ --mount=type=cache,sharing=shared,id=cargo_registry_cache,target=${CARGO_HOME}/registry/cache \
164+ --mount=type=cache,sharing=shared,id=cargo_git,target=${CARGO_HOME}/git/db \
165+ --mount=type=cache,sharing=shared,id=target_${TARGETARCH},target=/platform/target \
166+ export SCCACHE_SERVER_PORT=$((RANDOM+1025)) && \
167+ source $HOME/.cargo/env && \
168+ if [[ -z "${SCCACHE_MEMCACHED}" ]] ; then unset SCCACHE_MEMCACHED ; fi ; \
169+ RUSTFLAGS="-C target-feature=-crt-static" \
170+ CARGO_TARGET_DIR="/platform/target" \
171+ # TODO: Build wasm with build.rs
172+ # Meanwhile if you want to update wasm-bindgen you also need to update version in:
173+ # - packages/wasm-dpp/Cargo.toml
174+ # - packages/wasm-dpp/scripts/build-wasm.sh
175+ cargo install --profile "$CARGO_BUILD_PROFILE" [email protected] [email protected] --locked 175176
176177#
177178# Rust build planner to speed up builds
178179#
179180FROM deps AS build-planner
180181WORKDIR /platform
181182COPY . .
182- # RUN source $HOME/.cargo/env && \
183- # cargo chef prepare --recipe-path recipe.json
183+ RUN source $HOME/.cargo/env && \
184+ cargo chef prepare --recipe-path recipe.json
184185
185186# Workaround: as we cache dapi-grpc, its build.rs is not rerun, so we need to touch it
186187RUN touch /platform/packages/dapi-grpc/build.rs
@@ -201,47 +202,47 @@ WORKDIR /platform
201202COPY --from=build-planner /platform/recipe.json recipe.json
202203
203204# Build dependencies - this is the caching Docker layer!
204- # RUN --mount=type=cache,sharing=shared,id=cargo_registry_index,target=${CARGO_HOME}/registry/index \
205- # --mount=type=cache,sharing=shared,id=cargo_registry_cache,target=${CARGO_HOME}/registry/cache \
206- # --mount=type=cache,sharing=shared,id=cargo_git,target=${CARGO_HOME}/git/db \
207- # --mount=type=cache,sharing=shared,id=target_${TARGETARCH},target=/platform/target \
208- # source $HOME/.cargo/env && \
209- # export SCCACHE_SERVER_PORT=$((RANDOM+1025)) && \
210- # if [[ -z "${SCCACHE_MEMCACHED}" ]] ; then unset SCCACHE_MEMCACHED ; fi ; \
211- # cargo chef cook \
212- # --recipe-path recipe.json \
213- # --profile "$CARGO_BUILD_PROFILE" \
214- # --package drive-abci \
215- # --locked && \
216- # if [[ "${RUSTC_WRAPPER}" == "sccache" ]] ; then sccache --show-stats; fi
205+ RUN --mount=type=cache,sharing=shared,id=cargo_registry_index,target=${CARGO_HOME}/registry/index \
206+ --mount=type=cache,sharing=shared,id=cargo_registry_cache,target=${CARGO_HOME}/registry/cache \
207+ --mount=type=cache,sharing=shared,id=cargo_git,target=${CARGO_HOME}/git/db \
208+ --mount=type=cache,sharing=shared,id=target_${TARGETARCH},target=/platform/target \
209+ source $HOME/.cargo/env && \
210+ export SCCACHE_SERVER_PORT=$((RANDOM+1025)) && \
211+ if [[ -z "${SCCACHE_MEMCACHED}" ]] ; then unset SCCACHE_MEMCACHED ; fi ; \
212+ cargo chef cook \
213+ --recipe-path recipe.json \
214+ --profile "$CARGO_BUILD_PROFILE" \
215+ --package drive-abci \
216+ --locked && \
217+ if [[ "${RUSTC_WRAPPER}" == "sccache" ]] ; then sccache --show-stats; fi
217218
218219COPY . .
219220
220221RUN mkdir /artifacts
221222
222223# Build Drive ABCI
223- # RUN --mount=type=cache,sharing=shared,id=cargo_registry_index,target=${CARGO_HOME}/registry/index \
224- # --mount=type=cache,sharing=shared,id=cargo_registry_cache,target=${CARGO_HOME}/registry/cache \
225- # --mount=type=cache,sharing=shared,id=cargo_git,target=${CARGO_HOME}/git/db \
226- # --mount=type=cache,sharing=shared,id=target_${TARGETARCH},target=/platform/target \
227- # source $HOME/.cargo/env && \
228- # export SCCACHE_SERVER_PORT=$((RANDOM+1025)) && \
229- # if [[ "${CARGO_BUILD_PROFILE}" == "release" ]] ; then \
230- # mv .cargo/config-release.toml .cargo/config.toml && \
231- # export OUT_DIRECTORY=release ; \
232- # else \
233- # export FEATURES_FLAG="--features=console,grovedbg" ; \
234- # export OUT_DIRECTORY=debug ; \
235- #
236- # fi && \
237- # if [[ -z "${SCCACHE_MEMCACHED}" ]] ; then unset SCCACHE_MEMCACHED ; fi ; \
238- # cargo build \
239- # --profile "${CARGO_BUILD_PROFILE}" \
240- # --package drive-abci \
241- # ${FEATURES_FLAG} \
242- # --locked && \
243- # cp /platform/target/${OUT_DIRECTORY}/drive-abci /artifacts/ && \
244- # if [[ "${RUSTC_WRAPPER}" == "sccache" ]] ; then sccache --show-stats; fi
224+ RUN --mount=type=cache,sharing=shared,id=cargo_registry_index,target=${CARGO_HOME}/registry/index \
225+ --mount=type=cache,sharing=shared,id=cargo_registry_cache,target=${CARGO_HOME}/registry/cache \
226+ --mount=type=cache,sharing=shared,id=cargo_git,target=${CARGO_HOME}/git/db \
227+ --mount=type=cache,sharing=shared,id=target_${TARGETARCH},target=/platform/target \
228+ source $HOME/.cargo/env && \
229+ export SCCACHE_SERVER_PORT=$((RANDOM+1025)) && \
230+ if [[ "${CARGO_BUILD_PROFILE}" == "release" ]] ; then \
231+ mv .cargo/config-release.toml .cargo/config.toml && \
232+ export OUT_DIRECTORY=release ; \
233+ else \
234+ export FEATURES_FLAG="--features=console,grovedbg" ; \
235+ export OUT_DIRECTORY=debug ; \
236+
237+ fi && \
238+ if [[ -z "${SCCACHE_MEMCACHED}" ]] ; then unset SCCACHE_MEMCACHED ; fi ; \
239+ cargo build \
240+ --profile "${CARGO_BUILD_PROFILE}" \
241+ --package drive-abci \
242+ ${FEATURES_FLAG} \
243+ --locked && \
244+ cp /platform/target/${OUT_DIRECTORY}/drive-abci /artifacts/ && \
245+ if [[ "${RUSTC_WRAPPER}" == "sccache" ]] ; then sccache --show-stats; fi
245246
246247#
247248# STAGE: BUILD JAVASCRIPT INTERMEDIATE IMAGE
@@ -253,40 +254,40 @@ ENV SCCACHE_S3_KEY_PREFIX=${SCCACHE_S3_KEY_PREFIX}/wasm/wasm32
253254
254255WORKDIR /platform
255256
256- # COPY --from=build-planner /platform/recipe.json recipe.json
257+ COPY --from=build-planner /platform/recipe.json recipe.json
257258
258259# Build dependencies - this is the caching Docker layer!
259- # RUN --mount=type=cache,sharing=shared,id=cargo_registry_index,target=${CARGO_HOME}/registry/index \
260- # --mount=type=cache,sharing=shared,id=cargo_registry_cache,target=${CARGO_HOME}/registry/cache \
261- # --mount=type=cache,sharing=shared,id=cargo_git,target=${CARGO_HOME}/git/db \
262- # --mount=type=cache,sharing=shared,id=target_${TARGETARCH},target=/platform/target \
263- # source $HOME/.cargo/env && \
264- # export SCCACHE_SERVER_PORT=$((RANDOM+1025)) && \
265- # if [[ -z "${SCCACHE_MEMCACHED}" ]] ; then unset SCCACHE_MEMCACHED ; fi ; \
266- # cargo chef cook \
267- # --recipe-path recipe.json \
268- # --profile "$CARGO_BUILD_PROFILE" \
269- # --package wasm-dpp \
270- # --target wasm32-unknown-unknown \
271- # --locked && \
272- # if [[ "${RUSTC_WRAPPER}" == "sccache" ]] ; then sccache --show-stats; fi
260+ RUN --mount=type=cache,sharing=shared,id=cargo_registry_index,target=${CARGO_HOME}/registry/index \
261+ --mount=type=cache,sharing=shared,id=cargo_registry_cache,target=${CARGO_HOME}/registry/cache \
262+ --mount=type=cache,sharing=shared,id=cargo_git,target=${CARGO_HOME}/git/db \
263+ --mount=type=cache,sharing=shared,id=target_${TARGETARCH},target=/platform/target \
264+ source $HOME/.cargo/env && \
265+ export SCCACHE_SERVER_PORT=$((RANDOM+1025)) && \
266+ if [[ -z "${SCCACHE_MEMCACHED}" ]] ; then unset SCCACHE_MEMCACHED ; fi ; \
267+ cargo chef cook \
268+ --recipe-path recipe.json \
269+ --profile "$CARGO_BUILD_PROFILE" \
270+ --package wasm-dpp \
271+ --target wasm32-unknown-unknown \
272+ --locked && \
273+ if [[ "${RUSTC_WRAPPER}" == "sccache" ]] ; then sccache --show-stats; fi
273274
274275COPY . .
275276
276- # RUN --mount=type=cache,sharing=shared,id=cargo_registry_index,target=${CARGO_HOME}/registry/index \
277- # --mount=type=cache,sharing=shared,id=cargo_registry_cache,target=${CARGO_HOME}/registry/cache \
278- # --mount=type=cache,sharing=shared,id=cargo_git,target=${CARGO_HOME}/git/db \
279- # --mount=type=cache,sharing=shared,id=target_wasm,target=/platform/target \
280- # --mount=type=cache,sharing=shared,id=unplugged_${TARGETARCH},target=/tmp/unplugged \
281- # source $HOME/.cargo/env && \
282- # cp -R /tmp/unplugged /platform/.yarn/ && \
283- # yarn install --inline-builds && \
284- # cp -R /platform/.yarn/unplugged /tmp/ && \
285- # export SCCACHE_SERVER_PORT=$((RANDOM+1025)) && \
286- # if [[ -z "${SCCACHE_MEMCACHED}" ]] ; then unset SCCACHE_MEMCACHED ; fi ; \
287- # export SKIP_GRPC_PROTO_BUILD=1 && \
288- # yarn build && \
289- # if [[ "${RUSTC_WRAPPER}" == "sccache" ]]; then sccache --show-stats; fi
277+ RUN --mount=type=cache,sharing=shared,id=cargo_registry_index,target=${CARGO_HOME}/registry/index \
278+ --mount=type=cache,sharing=shared,id=cargo_registry_cache,target=${CARGO_HOME}/registry/cache \
279+ --mount=type=cache,sharing=shared,id=cargo_git,target=${CARGO_HOME}/git/db \
280+ --mount=type=cache,sharing=shared,id=target_wasm,target=/platform/target \
281+ --mount=type=cache,sharing=shared,id=unplugged_${TARGETARCH},target=/tmp/unplugged \
282+ source $HOME/.cargo/env && \
283+ cp -R /tmp/unplugged /platform/.yarn/ && \
284+ yarn install --inline-builds && \
285+ cp -R /platform/.yarn/unplugged /tmp/ && \
286+ export SCCACHE_SERVER_PORT=$((RANDOM+1025)) && \
287+ if [[ -z "${SCCACHE_MEMCACHED}" ]] ; then unset SCCACHE_MEMCACHED ; fi ; \
288+ export SKIP_GRPC_PROTO_BUILD=1 && \
289+ yarn build && \
290+ if [[ "${RUSTC_WRAPPER}" == "sccache" ]]; then sccache --show-stats; fi
290291
291292#
292293# STAGE: FINAL DRIVE-ABCI IMAGE
@@ -305,15 +306,15 @@ RUN mkdir -p /var/log/dash \
305306 /var/lib/dash/rs-drive-abci/db \
306307 ${REJECTIONS_PATH}
307308
308- # COPY --from=build-drive-abci /artifacts/drive-abci /usr/bin/drive-abci
309+ COPY --from=build-drive-abci /artifacts/drive-abci /usr/bin/drive-abci
309310COPY --from=build-drive-abci /platform/packages/rs-drive-abci/.env.mainnet /var/lib/dash/rs-drive-abci/.env
310311
311312# Create a volume
312313VOLUME /var/lib/dash/rs-drive-abci/db
313314VOLUME /var/log/dash
314315
315316# Double-check that we don' t have missing deps
316- # RUN ldd /usr/bin/drive-abci
317+ RUN ldd /usr/bin/drive-abci
317318
318319#
319320# Create new non-root user
0 commit comments