forked from ref-finance/ref-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_docker.sh
29 lines (22 loc) · 900 Bytes
/
build_docker.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
#!/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 )"
NAME="build_ref_farming"
if docker ps -a --format '{{.Names}}' | grep -Eq "^${NAME}\$"; then
echo "Container exists"
else
docker create \
--mount type=bind,source=$DIR/..,target=/host \
--cap-add=SYS_PTRACE --security-opt seccomp=unconfined \
--name=$NAME \
-w /host/ref-farming \
-e RUSTFLAGS='-C link-arg=-s' \
-it \
nearprotocol/contract-builder \
/bin/bash
fi
docker start $NAME
docker exec -it $NAME /bin/bash -c "rustup toolchain install stable-2020-10-08;rustup default stable-2020-10-08;rustup target add wasm32-unknown-unknown; cargo build --target wasm32-unknown-unknown --release"
mkdir -p res
cp $DIR/../target/wasm32-unknown-unknown/release/ref_farming.wasm $DIR/../res/ref_farming_release.wasm