forked from zavodil/near-staking-pool-owner
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build_docker_m1.sh
executable file
·30 lines (23 loc) · 987 Bytes
/
build_docker_m1.sh
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
#!/usr/bin/env bash
# Exit script as soon as a command fails.
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
DOCKER_NAME="build_contract"
FOLDER="near-staking-pool-owner"
if docker ps -a --format '{{.Names}}' | grep -Eq "^${DOCKER_NAME}\$"; then
echo "Container exists"
else
docker create \
--mount type=bind,source=$DIR/..,target=/host \
--cap-add=SYS_PTRACE --security-opt seccomp=unconfined \
--name=$DOCKER_NAME \
-w /host/$FOLDER \
-e RUSTFLAGS='-C link-arg=-s' \
-it \
contract-builder \
/bin/bash
fi
docker start $DOCKER_NAME
docker exec -it $DOCKER_NAME /bin/bash -c "rustup toolchain install stable-2021-10-21; rustup default stable-2021-10-21; rustup target add wasm32-unknown-unknown; cargo build --target wasm32-unknown-unknown --manifest-path ./../$FOLDER/contract/Cargo.toml --release"
mkdir -p out
cp $DIR/contract/target/wasm32-unknown-unknown/release/contract.wasm $DIR/out/release.wasm