utunga / homesafe

Decentralized, React-native, SSB based Mobile App for location based safety and messaging
1 stars 2 forks source link

Public docker development environment ready to go for for ssb mobile development #1

Open utunga opened 5 years ago

utunga commented 5 years ago

What

A pre-configured development environment for development on ssb / react-native / android stack with support for typescript and hot-reload.

The primary definition of success is it should be possible to develop on ManyVerse using the docker instance, as explained in more detail in the details section below. As an added extra it would be good to be able to develop on this repo as well (but hopefully that requires not extra work). Other nice to haves are also outlined below.

Not looking for the IDE just the ability to build and deploy to Android simulator (or connected device).

(NB: This is the first issue I'm posting to gitcoin so would very much appreciate any feedback or guidance as to the way I'm doing this.

Why

Luandro and I (and anecdotally many others) are both in a similar boat of not being able to get started with development for mobile ssb apps because we have difficulty getting started. For instance, when I run react-native run-android I get build/compilation failures (often libsodium related) or if it does build it crashes on first load

It'd be super great to enable people to start working on more ssb apps using the ssb, react-native, type-script, android stack without the current massive hassle required to just get started.

To be clear the objective is not solely to foster development on ManyVerse though that would be a nice side effect. Manyverse was chosen as the target because it is a project that already builds and has a lot of functionality in it, so it creates a clearly defined goal to be able to 'build' that stack..

Details

Clarification about Docker

I'm not wedded to Docker as the only way to solve this problem. The key point is that it is possible to build the dependencies and get up and running nice and fast without having to go crazy trying to install a million things to Android Studio or to install specific versions of Node via nvm or specific C++ libraries via NPM, Brew and such.

If, for instance, a Vagrant script or some other type of automation is better way to do this very happy to consider anything (It might be best to discuss first though before spending too much time on a particular approach).

I am a little unsure how things like Android Studio would work. Perhaps Android Studio could run on the host machine (outside of the Docker) but the builds be completed entirely at the command line. To be honest I'm not sure if/how/whether that would work, so welcome feedback on how to solve htat.

Nice to have extras

As mentioned this is the first item I'm posting on gitcoin. Hoping I've priced it correctly for the minimum above, but in the case that I underpriced this and if you feel so inclined (or if you are seeing this 'issue' outside of gitcoin context. Some other nice to haves include:

gitcoinbot commented 5 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 2.5 ETH (609.38 USD @ $243.75/ETH) attached to it as part of the factbenchmark fund.

utunga commented 5 years ago

The main 'issues' register - that the creator of ManyVerse (Andre Staltz) looks at - is over on gitlab so you may also wish to go there to see if there is discussion about this 'issue' there. https://gitlab.com/staltz/manyverse/issues/401

gitcoinbot commented 5 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work has been started.

These users each claimed they can complete the work by 1 day, 18 hours from now. Please review their action plans below:

1) mul1sh has been approved to start work.

Hi Utunga,

I've encountered a simillar situation before in building react-native apps that have many dependencies which results in tons of build errors and the best solution I've gotten thus far is the use of shell scripts.

So basically i'll come up with a shell script that builds all the necessary dependencies for android/iOS and makes it easy to deploy the project nice and easy. With this in mind I can work on this over the weekend and get it done by Monday, thanks. 2) zhaoyi0113 has applied to start work _(Funders only: approve worker | reject worker)_.

I am glad to see a docker application here. With many years of using docker, I have extensive experience about setting up docker for testing / staging / production etc. I have used docker for different scenarios.

Learn more on the Gitcoin Issue Details page.

utunga commented 5 years ago

Discussion with @mul1sh in pm... Looks like we may have a solution but am going to wait a bit longer just to see who else is keen to work on this one.

mul1sh commented 5 years ago

@utunga no worries take your time 😃

gitcoinbot commented 5 years ago

@mul1sh Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

gitcoinbot commented 5 years ago

@mul1sh Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

mul1sh commented 5 years ago

@gitcoinbot i'm still working on this 😺 about to PR

utunga commented 5 years ago

Yay! Can't wait!

:-)

On Fri, May 24, 2019 at 4:18 AM Mulili Nzuki notifications@github.com wrote:

@gitcoinbot https://github.com/gitcoinbot i'm still working on this 😺 about to PR

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/utunga/homesafe/issues/1?email_source=notifications&email_token=AABIXU3NVFCA6DGQGEBQEYDPW27UPA5CNFSM4HNRPYCKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWCXVVY#issuecomment-495286999, or mute the thread https://github.com/notifications/unsubscribe-auth/AABIXUY2Q3E2OA7XQIFLF3TPW27UPANCNFSM4HNRPYCA .

utunga commented 5 years ago

That said, also, take the time you need

On Fri, May 24, 2019 at 4:19 AM Miles Thompson utunga@gmail.com wrote:

Yay! Can't wait!

:-)

On Fri, May 24, 2019 at 4:18 AM Mulili Nzuki notifications@github.com wrote:

@gitcoinbot https://github.com/gitcoinbot i'm still working on this 😺 about to PR

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/utunga/homesafe/issues/1?email_source=notifications&email_token=AABIXU3NVFCA6DGQGEBQEYDPW27UPA5CNFSM4HNRPYCKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWCXVVY#issuecomment-495286999, or mute the thread https://github.com/notifications/unsubscribe-auth/AABIXUY2Q3E2OA7XQIFLF3TPW27UPANCNFSM4HNRPYCA .

mul1sh commented 5 years ago

@utunga will do but i want to do a WIP PR so that you see my work so far and also get incremental updates as I work on the issue 🙂

mul1sh commented 5 years ago

@utunga btw i've just realized this issue talks of a gitlab repo called manyverse but all along i've been working targeting this repo homesafe. So should I instead work from the gitlab repo?

utunga commented 5 years ago

@mul1sh sorry.. yes please, that was the idea. Does it work for HomeSafe already? Because maybe I could review?

There is a caveat and my apologies I didn't realise this earlier but this issue on ManyVerse https://gitlab.com/staltz/manyverse/issues/296 is sort of a crucial one - which boils down to the fact that you can't debug with an emulator you have to use a real device over USB debugging - for reasons described in that issue.

mul1sh commented 5 years ago

@utunga sorry no its not done, this is just the scaffolding i've done so far, I was waiting for your clarification before continuing to work on this.

So just to be clear, I should instead target the manyverse gitlab repo and not this one correct? If thats the case what exactly should be done to homesafe/ this repo?

Actually after looking at the manyverse repo in depth, it all makes sense now. So i'll make a merge request to the manyverse repo with the Dockerfile + sh scripts.

Also for the caveat, thats fine I android also supports arm images for emulators but they are much slower than the x86 ones and of course I have an android device to test with so this is not an issue for me :)

utunga commented 5 years ago

Thanks @mul1sh yes please. And yes I think that creating a merge request directly on the gltlab manyverse repo iis a fine way to do this.

The reason I created the gitcoin bounty over here is because gitcoin doesn't support gitlab, and also because I don't have control over the manyverse repo. Hmm or, if you prefer you could create the PR on my fork of repo over on gitlab - here https://gitlab.com/utunga/manyverse . Up to you.

When you do create the merge request please prefix it with "dx:" (for developer experience, per this comment from Andre just now).

In the meantime I'm going to look into ARM emulators on my macbook because my usb connection to my tired old phone is very dodgy and frustating.

utunga commented 5 years ago

PS Guess they stopped releasing ARM images after API level 25 but that's OK..

Preparing "Install Google APIs ARM EABI v7a System Image (revision: 16)".
Downloading https://dl.google.com/android/repository/sys-img/google_apis/armeabi-v7a-25_r16.zip

PS I finally have ManyVerse building and deploying on my machine - though admittedly it crashes right after launch - but even if I do have it working it took altogether too long to get up and running so a docker image for new devs would be awesome.

utunga commented 5 years ago

sooooooooo.... sloooooooowww....

mul1sh commented 5 years ago

Ok i'll fork and work from your gitlab repo then and also take into consideration Andre's comment.

Also hahaha yeah thats the problem with ARM emulators they are super slow regardless of the specs of your machine, thats why the x86 ones are preferred. Anyway no worries i'll use my phone instead for testing and also fix all the crashes that are happening.

utunga commented 5 years ago

Awesome. FWIW I just filed the following 'issue' on Andre's repo. But he has stated (in another forum) that he won't have time to work on 'dx' (aka developer experience) issues for some time so I'm hoping that you will have better luck than I.

Also PPS everything related to the homesaferepo (aka this repo) is in the 'nice to have' extras category but if we could get it so that it could build, specifically getting past the node_sodium refusal to build that would be super awesome.. because I am still getting this error when I try to build that one.. but let me say again - this is a nice to have as far as the gitcoin bounty goes. The goal, as stated there is just to get ManyVerse to build and load in debug mode.

npm verb pkgid sodium-native@2.3.0
npm verb cwd /Users/utunga/dev/homesafe/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-arm64-v8a/nodejs-project
npm verb Darwin 18.5.0
npm verb argv "/Users/utunga/.nvm/versions/node/v10.13.0/bin/node" "/Users/utunga/.nvm/versions/node/v10.13.0/bin/npm" "--verbose" "rebuild" "--build-from-source"
npm verb node v10.13.0
npm verb npm  v6.4.1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sodium-native@2.3.0 install: `node-gyp-build "node preinstall.js" "node postinstall.js"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sodium-native@2.3.0 install script.
utunga commented 5 years ago

Above issue now fixed fwiw. Any word on progress @mul1sh ?

mul1sh commented 5 years ago

@utunga thats awesome, on my end i'm almost I've managed to come with a docker file that can build and run the manyverse apk in both a simulator and android phone. Though I had some issues in getting the android sdk to work correctly so i'm testing make this is fixed and then I open a merge request in gitlab in a few hours.

And then tomorrow I take care of this repo and we should be done 😃

utunga commented 5 years ago

Hey @mul1sh so excited by both of these things. I really hope you have good luck with doing this.

FWIW I'm quite excited by the idea of being able to run ManyVerse in the emulator - hopefully you mean the x86 emulator - because running with a real phone is proving to be a real problem for me. My old phone up and died and when I finally got a replacement, using it as a USB Debugging target seems to be related to causing it to overheat and stop working. Admittedlt this is probably just my phone but still being able to run in the emulator would be great.

That said if it's only in the Arm7 emulator that's fine too and anyway I am just as excited by the idea that we can run this repo in the emulator - specifically getting past the 'can't build libsodium' problem would be a game changer. Feel free to propose a PR on the actual code if that's what is needed to make this work. (I vaguely understand that libsodium folks have been moving to compiling to web assembly so maybe that's the way to solve this problem (though I admit I don't know enough about it ) Understand that 'this' repo is a nice to have but whatever you get to very much looking forward to it.

Thanks

gitcoinbot commented 5 years ago

@mul1sh Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

gitcoinbot commented 5 years ago

@mul1sh Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

mul1sh commented 5 years ago

@utunga sorry again for the delay, the android sdk's configuration in OSX really gave me a tough time but i've managed to sort them now. So final question before I finally do the MR, it seems manyverse has a lot of scripts which can be ran via the cli i.e. for building the backend/assets e.t.c

So with this in mind can I also include a Makefile that contains the various commands (i.e. hot-reload) that will allow a user to ran the scripts from the cli instead of ssh into the docker image?

utunga commented 5 years ago

Hey @mul1sh great to see your post again today. Don't worry about the cli scripts mate, it's a great idea but want you to just be sure to get this bounty with all the hard work you've done. Looking forward to seeing the PR.

FWIW I am familiar with the pattern of using a makefile + docker as a convenient way to run scripts from CLI - pretty much what I do in the day job all the time so I'll probably have a go at that after we get this up. Sounds like a good way to deal with those things like hot-reload.

Also, did you want me to extend the timelimit on the bounty? It sounds like you are almost there so I am thinking just to leave it but if you want me to I'd be happy to do so.

Thanks

mul1sh commented 5 years ago

@utunga sounds great then, i'll leave the Dockerfile as is for now.

As promised here is the MR https://gitlab.com/utunga/manyverse/merge_requests/1 . I have tested it thoroughly and its working on my end but kindly try it out and see if you are able to easily setup manyverse and deploy it to an android device.

As for the time limit extension, yes definitely, kindly extend it to Monday so that I also get to work on this repo too and also the nice to haves over the weekend till you are satisified 😃 . Anyway thanks again for the patience, I appreciate it, kindly also lets continue the discussion on the gitlab MR to avoid filling up this thread like the gitcoin bot does 😂

utunga commented 5 years ago

that's fantatsic @mul1sh .. i've extended the deadline and will continue conversation over on the MR (for future reference, over here ... https://gitlab.com/utunga/manyverse/merge_requests/1)

gitcoinbot commented 5 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 2.5 ETH (675.21 USD @ $270.08/ETH) has been submitted by:

  1. @mul1sh

@utunga please take a look at the submitted work:


arj03 commented 5 years ago

Above issue now fixed fwiw. Any word on progress @mul1sh ?

@utunga how did you fix that?

utunga commented 5 years ago

@arj03 I guess that's why we're setting up this Docker - so that we can reliably build. Because unfortunately, all I can tell you is that I installed a lot of different configurations of the various Android SDK bits and pieces and eventually the dang thing worked! ;-)

A couple of key things I needed to realize:

  1. I shouldn't expect to run ManyVerse in the x86 based emulator on MacOS I have to use a 'real' device - which is Arm based or an Arm-based emulator (they discontinued Arm based emulatators at Android 25 because they were so slow).

  2. The key lies in getting the right versions of the SDK installed.

If you look at the docker file that @mul1sh has been working on - over here https://gitlab.com/mulish/manyverse/blob/master/Dockerfile it will give you a much more specific list of the dependencies needed. This could be of use even if you don't go down the route of building from the docker.

That said if you followed the insutrctions that @mul1sh added to the README and see if it works for you that would be super awesome because, it would be greaet to get feedback on that one.

Once I have been able to verify that this approach actually works I'll be creating a PR to request added the Dockerfile back into AndreStaltz's primary Manyverse repo. (on gitlab)

gitcoinbot commented 5 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


The funding of 2.5 ETH (777.16 USD @ $310.86/ETH) attached to this issue has been approved & issued to @mul1sh.

Thanks to @vs77bb for their crowdfunded contributions to this bounty.