From 2eeb70e4991037612956638d1238325d7ef580dd Mon Sep 17 00:00:00 2001 From: Aditya Kalia Date: Thu, 21 Apr 2022 15:30:41 +0530 Subject: [PATCH] Logic for handling git dependencies --- Dockerfile | 5 +++-- README.md | 17 +++++++++++++++++ optimize.sh | 1 + optimize_workspace.sh | 1 + 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 108bf3a..b5d9d9b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -79,9 +79,10 @@ RUN cd build_workspace && \ # FROM rust:1.60.0-alpine as base-optimizer -# Being required for gcc linking +# musl-dev is required for gcc linking. +# Adding Git for usage within projects that use `git-fetch-with-cli = true`. RUN apk update && \ - apk add --no-cache musl-dev + apk add --no-cache musl-dev git # Setup Rust with Wasm support RUN rustup target add wasm32-unknown-unknown diff --git a/README.md b/README.md index 98787cd..05d9849 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,23 @@ docker run --rm -v "$(pwd)":/code \ Demo this with `cosmwasm-examples` (going into eg. `erc20` subdir before running), with `cosmwasm-plus`, or with a sample app from `cosmwasm-template`. +### Configuring Private Repo Dependencies + +SSH credentials for fetching private repo dependencies can be configured through environment variable `GIT_CREDENTIALS` + +```sh +docker run -e GIT_CREDENTIALS=https://:@github.com --rm -v "$(pwd)":/code \ + --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ + --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ + cosmwasm/rust-optimizer:0.12.6 +``` + + +**Note**: *This makes reproducible builds somewhere between hard and impossible.* + + +## Caching + Note that we use one registry cache (to avoid excessive downloads), but the target cache is a different volume per contract that we compile. This means no interference between contracts, but very fast recompile times when making minor adjustments to a contract you had previously created an optimized build for. diff --git a/optimize.sh b/optimize.sh index 7e22145..5fac0cf 100755 --- a/optimize.sh +++ b/optimize.sh @@ -4,6 +4,7 @@ set -o errexit -o nounset -o pipefail command -v shellcheck >/dev/null && shellcheck "$0" +[ -n "${GIT_CREDENTIALS=""}" ] && echo "$GIT_CREDENTIALS" >~/.git-credentials && git config --global credential.helper store export PATH=$PATH:/root/.cargo/bin # Suffix for non-Intel built artifacts diff --git a/optimize_workspace.sh b/optimize_workspace.sh index 43e2670..36cb312 100644 --- a/optimize_workspace.sh +++ b/optimize_workspace.sh @@ -4,6 +4,7 @@ set -o errexit -o nounset -o pipefail command -v shellcheck >/dev/null && shellcheck "$0" +[ -n "${GIT_CREDENTIALS:=""}" ] && echo "$GIT_CREDENTIALS" >~/.git-credentials && git config --global credential.helper store export PATH="$PATH:/root/.cargo/bin" # Suffix for non-Intel built artifacts