aragon / aragon-cli

CLI for creating and publishing Aragon apps
GNU General Public License v3.0
91 stars 79 forks source link

running Aragon in docker for development #374

Closed scottrepreneur closed 5 years ago

scottrepreneur commented 5 years ago

Trying to get Aragon running in a docker instance for development environment abstraction. Will eventually have a dockerfile, but the permissions have been giving me touble. The new cli seems to get further through the run process, but I'm getting a new error.

To recreate and jump into a nodejs container: docker run -it node bash

I've found there is some trouble with permissions for gyp and go-ipfs so the unsafe permission option helps to succeed the install

:/home# npm i -g @aragon/cli --unsafe-perm
...
+ @aragon/cli@5.4.0-beta.1
added 1628 packages from 1329 contributors in 208.793s

Create the app

:/home# npx create-aragon-app test
npx: installed 124 in 5.549s
 ✔ Preparing initialization
 ✔ Cloning app template
 ✔ Preparing template
 ✔ Installing package dependencies
 ✔ Created new application test.aragonpm.eth in test

Run the app

:/home/test# aragon run
 ✔ Start a local Ethereum network
 ✔ Check IPFS 
 ✔ Publish app to APM
 ✔ Create DAO
 ✔ Open DAO
 ℹ You are now ready to open your app in Aragon.
 ℹ Here are some Ethereum accounts you can use.
  The first one will be used for all the actions the CLI performs.
  You can use your favorite Ethereum provider or wallet to import their private keys.

Address #1:  0xb4124cEB3451635DAcedd11767f004d8a28c6eE7 (this account is used to deploy DAOs, it has more permissions)
Private key: a8a54b2d8197bc0b19bb8a084031be71835580a01e70a45a13babd16c9bc1563
Address #2:  0x8401Eb5ff34cc943f096A32EF3d5113FEbE8D4Eb 
Private key: ce8e3bda3b44269c147747a373646393b1504bfcbb73fc9564f5d753d8116608
 ℹ The accounts were generated from the following mnemonic phrase:
explain tackle mirror kit van hammer degree position ginger unfair soup bonus

 ℹ This is the configuration for your development deployment:
    Ethereum Node: ws://localhost:8545
    ENS registry: 0x5f6f7e8cc7346a11ca2def8f827b7a0b612c56a1
    APM registry: aragonpm.eth
    DAO address: 0x5b6a3301a67A4bfda9D3a528CaD34cac6e7F8070

    Opening http://localhost:3000/#/0x5b6a3301a67A4bfda9D3a528CaD34cac6e7F8070 to view your DAO
(node:9423) UnhandledPromiseRejectionWarning: Error: Exited with code 3
    at ChildProcess.cp.once.code (/usr/local/lib/node_modules/@aragon/cli/node_modules/opn/index.js:84:13)
    at Object.onceWrapper (events.js:285:13)
    at ChildProcess.emit (events.js:197:13)
    at maybeClose (internal/child_process.js:978:16)
    at Socket.stream.socket.on (internal/child_process.js:395:11)
    at Socket.emit (events.js:197:13)
    at Pipe._handle.close (net.js:611:12)
(node:9423) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:9423) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Nothing loads at the address provided http://localhost:3000/#/0x5b6a3301a67A4bfda9D3a528CaD34cac6e7F8070

sohkai commented 5 years ago

This looks like an issue with opn and us trying to open a browser with the Aragon client through the docker instance.

@scottrepreneur can you see if running aragon run with --no-client still gives you the error? You'd still need the correct ports to be accessible from docker (I think this would just be 8545 for the ganache node and 8080 for the ipfs gateway) to connect a local Aragon client (http://github.com/aragon/aragon).

scottrepreneur commented 5 years ago

Nice! Can't believe I forgot the ports, thanks @sohkai. I also added port 3000, so I can pull that up in my browser now.

docker run -it -p 8545:8545 -p 8080:8080 -p 3000:3000 node bash

It's not finding my org, because I think it's looking on the wrong network? I'm having trouble connecting Metamask to that Eth node. The cli output shows this ws://localhost:8545 but MM is asking for an http/https URI for custom nodes. URIs require the appropriate HTTP/HTTPS prefix. I've tried http://localhost:8545 to no avail. Is there something else I can try to verify that it's escaping the container?

organization not found

I'm still getting the error with opn like you mentioned, but it's not causing an issue reaching the dashboard.

scottrepreneur commented 5 years ago

actually, this may be an issue with Chrome OS, only. I'm getting this working in a Mac environment.

scottrepreneur commented 5 years ago

There does seem to be an issue deploying the app? I'm registering an Unknown app, but it doesn't appear to cite the permissions correctly. It should be looking for the default CounterApp. It's working for me outside docker on Mac.

screen shot 2019-02-25 at 7 30 48 pm
/home/test# aragon run --debug
Start a local Ethereum network [started]
Starting a local chain from snapshot [started]
Local chain started at port 8545 [title changed]
Local chain started at port 8545 [completed]
Start a local Ethereum network [completed]
Check IPFS [started]
Start IPFS [started]
→ Starting IPFS at port: 5001
Start IPFS [completed]
Add local files [started]
Add local files [completed]
Check IPFS [completed]
Publish app to APM [started]
Applying version bump (major) [started]
Applying version bump (major) [completed]
Deploy contract [started]
Compile contracts [started]
Compile contracts [completed]
Deploy 'CounterApp' to network [started]
→ Deploying 'CounterApp' to network
Deploy 'CounterApp' to network [completed]
Generate deployment artifacts [started]
Generate deployment artifacts [completed]
Deploy contract [completed]
Determine contract address for version [started]
Determine contract address for version [completed]
Building frontend [started]
→ npm run build:
> app-name@1.0.0 build /home/test
> npm run sync-assets && npm run build:app && npm run build:script

→ npm run build:
> app-name@1.0.0 sync-assets /home/test
> copy-aragon-ui-assets -n aragon-ui ./dist

→ npm run build:
Aragon UI assets copied to dist/aragon-ui

→ npm run build:
> app-name@1.0.0 build:app /home/test
> parcel build app/index.html -d dist/ --public-url '.' --no-cache

→ npm run build: ✨  Built in 19.48s.

→ npm run build:

→ npm run build: dist/main.8cca5d83.map    ⚠️  2.39 MB     252ms

→ npm run build: dist/main.f0aec9a3.js      776.23 KB    18.51s

→ npm run build: dist/index.html                148 B     609ms

→ npm run build:
> app-name@1.0.0 build:script /home/test
> parcel build app/script.js -d dist/ --no-cache

→ npm run build: ✨  Built in 12.35s.

→ npm run build:

→ npm run build: dist/script.map    ⚠️  1.42 MB     177ms

→ npm run build: dist/script.js      417.89 KB    11.88s

Building frontend [completed]
Prepare files for publishing [started]
Prepare files for publishing [completed]
Generate application artifact [started]
Generate application artifact [completed]
Publish test.aragonpm.eth [started]
→ Generating transaction and waiting for confirmation
Publish test.aragonpm.eth [completed]
Fetch published repo [started]
Fetch published repo [completed]
Publish app to APM [completed]
Create DAO [started]
Fetching kit bare-kit.aragonpm.eth@latest [started]
Fetching kit bare-kit.aragonpm.eth@latest [completed]
Create new DAO from kit [started]
Create new DAO from kit [completed]
Checking DAO [started]
Checking DAO [completed]
Create DAO [completed]
Open DAO [started]
Download client [started]
Download client [skipped]
→ Client already downloaded
Start Aragon client [started]
Start Aragon client [completed]
Open client [started]
Open client [completed]
Open DAO [completed]
 ℹ You are now ready to open your app in Aragon.
 ℹ Here are some Ethereum accounts you can use.
  The first one will be used for all the actions the CLI performs.
  You can use your favorite Ethereum provider or wallet to import their private keys.

Address #1:  0xb4124cEB3451635DAcedd11767f004d8a28c6eE7 (this account is used to deploy DAOs, it has more permissions)
Private key: a8a54b2d8197bc0b19bb8a084031be71835580a01e70a45a13babd16c9bc1563
Address #2:  0x8401Eb5ff34cc943f096A32EF3d5113FEbE8D4Eb
Private key: ce8e3bda3b44269c147747a373646393b1504bfcbb73fc9564f5d753d8116608
 ℹ The accounts were generated from the following mnemonic phrase:
explain tackle mirror kit van hammer degree position ginger unfair soup bonus

 ℹ This is the configuration for your development deployment:
    Ethereum Node: ws://localhost:8545
    ENS registry: 0x5f6f7e8cc7346a11ca2def8f827b7a0b612c56a1
    APM registry: aragonpm.eth
    DAO address: 0x5b48408a77645bd31e5eBaa460E84B588eaae1d4

    Opening http://localhost:3000/#/0x5b48408a77645bd31e5eBaa460E84B588eaae1d4 to view your DAO
sohkai commented 5 years ago

@scottrepreneur Weird, this is likely related to IPFS... are you connected to your localhost:8080 node? Does your app's arapp.json file contain all the roles (e.g. see the CounterApp's: https://github.com/aragon/aragon-react-boilerplate/blob/master/arapp.json#L2)?

MidnightLightning commented 5 years ago

I'm jumping in trying to start Aragon development using Docker containers as well, and ran across these same issues.

Will eventually have a dockerfile, but the permissions have been giving me trouble.

Me too; I see errors like the following when running npm i -g @aragon/cli inside a Docker container:

npm WARN deprecated natives@1.1.6: This module relies on Node.js's internals and will break at some point. Do not use it, and update to graceful-fs@4.x.

> scrypt@6.0.3 preinstall /usr/local/lib/node_modules/@aragon/cli/node_modules/scrypt
> node node-scrypt-preinstall.js

Error: Error: Command failed: ./configure
./configure: line 1904: config.log: Permission denied
./configure: line 1914: config.log: Permission denied

The "unsafe permission" flag worked for me to resolve that issue.

sohkai commented 5 years ago

@MidnightLightning Perhaps this is a problem with the default nodejs docker container, where installing global packages requires higher privileges due to the path (vs. tools like nvm where you'd be installing global packages into your home directory instead)?

MidnightLightning commented 5 years ago

Hmmm, not likely; when spinning up a Node container in Docker, the user that kicks off whatever command requested is root:

> docker run --rm -it node:latest bash
root@4ebaca798067:/# whoami
root

I'm thinking it more have something to do with the host OS running Docker, because the folder I am trying to install into (where it's creating the node_modules folder) is a shared mount between the Windows host OS and the Docker Node container. But for that part of the issue, using the --unsafe-perm flag on the call makes it succeed.

0xGabi commented 5 years ago

@scottrepreneur the issue with the Unknown app was that the IPFS content on the aragen snapshot been broke. Fixed in: https://github.com/aragon/aragen/pull/47