diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..ea6720feb --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +node_modules +builds +development \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..d06f5377b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM node:6 +MAINTAINER kumavis + +# setup app dir +RUN mkdir -p /www/ +WORKDIR /www/ + +# install dependencies +COPY ./package.json /www/package.json +RUN npm install + +# copy over app dir +COPY ./ /www/ + +# run tests +# RUN npm test + +# build app +RUN npm run dist + +# start server +CMD node mascara/example/server.js diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..58c046c32 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +metamascara: + build: ./ + restart: always + ports: + - "9001" + environment: + MASCARA_ORIGIN: "https://zero.metamask.io" + VIRTUAL_PORT: "9001" + VIRTUAL_HOST: "zero.metamask.io" + LETSENCRYPT_HOST: "zero.metamask.io" + LETSENCRYPT_EMAIL: "admin@metamask.io" \ No newline at end of file diff --git a/mascara/server/index.js b/mascara/server/index.js index 9fd664eee..14e3fa18e 100644 --- a/mascara/server/index.js +++ b/mascara/server/index.js @@ -8,10 +8,10 @@ module.exports = createMetamascaraServer function createMetamascaraServer(){ // start bundlers - const metamascaraBundle = createBundle('./src/mascara.js') - const proxyBundle = createBundle('./src/proxy.js') - const uiBundle = createBundle('./src/ui.js') - const backgroundBuild = createBundle('./src/background.js') + const metamascaraBundle = createBundle(__dirname + '/../src/mascara.js') + const proxyBundle = createBundle(__dirname + '/../src/proxy.js') + const uiBundle = createBundle(__dirname + '/../src/ui.js') + const backgroundBuild = createBundle(__dirname + '/../src/background.js') // serve bundles const server = express() diff --git a/mascara/src/mascara.js b/mascara/src/mascara.js index f9bed7e52..0fc2868e1 100644 --- a/mascara/src/mascara.js +++ b/mascara/src/mascara.js @@ -1,44 +1,41 @@ const Web3 = require('web3') const setupProvider = require('./lib/setup-provider.js') -const MASACARA_DOMAIN = 'http://localhost:9001' +const MASCARA_ORIGIN = process.env.MASCARA_ORIGIN || 'http://localhost:9001' +console.log('MASCARA_ORIGIN:', MASCARA_ORIGIN) // // setup web3 // -var provider = setupProvider({ - mascaraUrl: MASACARA_DOMAIN + '/proxy/', +const provider = setupProvider({ + mascaraUrl: MASCARA_ORIGIN + '/proxy/', }) instrumentForUserInteractionTriggers(provider) -var web3 = new Web3(provider) -web3.setProvider = function(){ - console.log('MetaMask - overrode web3.setProvider') -} - -// -// -// export web3 -// - +const web3 = new Web3(provider) global.web3 = web3 // // ui stuff // -var shouldPop = false -window.addEventListener('click', function(){ +let shouldPop = false +window.addEventListener('click', maybeTriggerPopup) + +// +// util +// + +function maybeTriggerPopup(){ if (!shouldPop) return shouldPop = false - window.open(MASACARA_DOMAIN, '', 'width=360 height=500') + window.open(MASCARA_ORIGIN, '', 'width=360 height=500') console.log('opening window...') -}) - +} function instrumentForUserInteractionTriggers(provider){ - var _super = provider.sendAsync.bind(provider) + const _super = provider.sendAsync.bind(provider) provider.sendAsync = function(payload, cb){ if (payload.method === 'eth_sendTransaction') { console.log('saw send') diff --git a/package.json b/package.json index b96197915..78a8520f4 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ ] } ], + "envify", "brfs" ] }, @@ -127,6 +128,7 @@ "clone": "^1.0.2", "deep-freeze-strict": "^1.1.1", "del": "^2.2.0", + "envify": "^4.0.0", "fs-promise": "^1.0.0", "gulp": "github:gulpjs/gulp#4.0", "gulp-if": "^2.0.1",