Skip to content

Add Dockerfile #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
FROM debian:buster

RUN apt update && \
# Install common dependencies
apt install -y \
cmake \
curl \
g++ \
gcc \
git \make \
wget \
# LLVM script
gnupg \
lsb-release \
software-properties-common \
# Electron
libasound2 \
libgdk-pixbuf2.0-0 \
libgtk-3-0 \
libnss3 \
libxcomposite1 \
libxcursor1 \
libxi6 \
libxss1 \
libxtst6 \
xvfb && \
# Install LLVM:12
curl -sSf https://apt.llvm.org/llvm.sh | bash -s -- 12 && \
ln -s $(which clang-12) /usr/bin/clang && \
# Install Node.js:14
curl -fsSL https://deb.nodesource.com/setup_14.x | bash - && \
apt install nodejs -y && \
# Install Rust nightly
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y \
--default-toolchain nightly \
--profile minimal \
--component clippy,rustfmt,rust-src \
--target wasm32-unknown-unknown && \
# Install wasm-opt from binaryen
git clone --depth 1 --branch version_100 https://github.com/WebAssembly/binaryen.git /binaryen && \
cd /binaryen && \
cmake . && \
make -j$(nproc) && \
make install && \
rm -rf /binaryen && \
# Remove apt files
rm -rf /var/lib/{apt,dpkg,cache,log}/

CMD Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & export DISPLAY=':99.0' && bash
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
build-node-%: export PAIR = $(subst +, ,$(subst build-node-,,$@))
build-node-%:
cargo build --package secp256k1-node --target $(firstword $(PAIR)) -Z build-std=panic_abort,std --release
cp -f target/$(firstword $(PAIR))/release/libsecp256k1_node.so lib/secp256k1-$(lastword $(PAIR)).so
mkdir -p lib && cp -f target/$(firstword $(PAIR))/release/libsecp256k1_node.so lib/secp256k1-$(lastword $(PAIR)).so
strip lib/secp256k1-$(lastword $(PAIR)).so

.PHONY: build-node-debug
Expand All @@ -13,7 +13,7 @@ build-node-debug:
build-node-debug-%: export PAIR = $(subst +, ,$(subst build-node-debug-,,$@))
build-node-debug-%:
cargo build --package secp256k1-node --target $(firstword $(PAIR))
cp -f target/$(firstword $(PAIR))/debug/libsecp256k1_node.so lib/secp256k1-$(lastword $(PAIR)).so
mkdir -p lib && cp -f target/$(firstword $(PAIR))/debug/libsecp256k1_node.so lib/secp256k1-$(lastword $(PAIR)).so

.PHONY: build-wasm
build-wasm:
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,23 @@ If `strict` is `true`, valid signatures with any of (r, s) values greater than `

---

## Docker Build / Development Environment

#### Build Docker image

```
docker build -t tiny-secp256k1 .
```

#### Run Docker container

```
docker run -it --rm -v `pwd`:/tiny-secp256k1 -w /tiny-secp256k1 tiny-secp256k1
# npm install --unsafe-perm
# make test
# make clean
```

## Credit

This library uses the native library [secp256k1](https://github.com/bitcoin-core/secp256k1) by the bitcoin-core developers through Rust crate [secp256k1-sys](https://crates.io/crates/secp256k1-sys), including derivatives of its tests and test vectors.
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@
"./lib/rand.js": "./lib/rand.browser.js",
"./lib/wasm_loader.js": "./lib/wasm_loader.browser.js"
},
"scripts": {
"postinstall": "patch-package --patch-dir ./util/patches"
},
"devDependencies": {
"binaryen": "^100.0.0",
"browser-run": "^8.0.0",
"buffer": "^6.0.3",
"patch-package": "^6.4.7",
"path-browserify": "^1.0.1",
"prettier": "^2.2.1",
"process": "^0.11.10",
Expand Down
18 changes: 18 additions & 0 deletions util/patches/electron-stream+8.0.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/node_modules/electron-stream/index.js b/node_modules/electron-stream/index.js
index 8524e59..5b89a67 100644
--- a/node_modules/electron-stream/index.js
+++ b/node_modules/electron-stream/index.js
@@ -79,8 +79,12 @@ Electron.prototype._onfinish = function(){
Electron.prototype._spawn = function(url){
debug('spawn %s', url);

+ var args = []
+ if (process.getuid() === 0) args.push("--no-sandbox");
+ args.push(runner);
+
var self = this;
- var ps = self.ps = spawn(electron, [runner], {
+ var ps = self.ps = spawn(electron, args, {
stdio: [null, null, null, 'ipc']
});