Docker Development on Apple M1 via Raspberry Pi: Live!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today uh today's gonna be fun we'll see if we succeed or fail so just last week i got my brand new can you see it m1 uh 13 inch macbook pro i have been so excited about getting this my prior machine was three years old and i really been looking forward to upgrading and using the new speed of the m1 however as a developer there's a major drawback right now it's uh currently mid-december 2020 and that is that docker for mac uh is not yet compatible with the m1 chip so i've been racking my brain about what to do about this because most of my development happens in docker so one idea i had is to use a raspberry pi to run docker on and do my development that way via my mac or i guess on my mac via the raspberry pi and there's something new i've learned about recently which is vs codes remote development extension which allows you to essentially run vs code on a client like your macbook but actually everything is happening on a computer elsewhere like a raspberry pi so in this video we are going to put together this raspberry pi i literally got it delivered today we're going to put it together we're going to install ubuntu on it ubuntu server we're going to get docker running on it and hopefully get everything tied up with vs code remote development this will be my first time running through this all the way through and so we'll see how it goes so let's start with uh the raspberry pi itself so here's the raspberry pi this is a raspberry pi 4 so it's the latest version and it's an eight gigabyte of ram and then it came with this uh 32 gig um micro sd card i bought the connect version so it came with this cool case and i have a fan and some heat sinks and so uh we're going to put this together the only thing i really haven't done anything yet the only thing i've done so far is i have pulled out the power cable and um an ethernet cable to use uh as we go so let's start putting this together um i should say i've i've had a few raspberry pi's before and prior to this video over the weekend i tried to um i tried to use one of my older raspberry pies to get this kind of setup going but i ran into an issue where the older raspberry pi's aren't compatible with some of the packages that i'm trying to use and it can't run the 64-bit version of ubuntu either so i had to uh upgrade here so let's place this in here and the guide has the guide that came with this says where to put these heatsinks so we're going to go ahead and place these heat sinks here so let's do that so this is the biggest heat sink i assume let's see what is this okay so this is going on [Music] the cpu here we go so place this on the cpu great and then the next one goes on the ram this is the next biggest one so we'll peel back the adhesive cover on it doo doo this one doesn't want to come off as easily come on there we go okay so this goes on the ram that's this part by the way i'm i'm just following the guide here i don't have this memorized i don't even think i had heat sinks on my old one okay there's that and then the third one where does that go the third one goes on the usb 3.0 controller so i'm going to peel this adhesive back okay and that one goes right here all right there we go so we have this uh bottom base of the case here and we just put on our one two three heat sinks uh on our various places as demonstrated by the guide and now it also came with this fan um now my last raspberry pi that might have had a heat sink but it definitely didn't have a fan so let's see what to do about that this is the top part of the case and it has a place to put the fan here but you have to plug it in somewhere so let's see what the guide says about that so it says if you intend to use a raspberry pi for high performance applications which we might be running a docker server then you might want to use the fan connect the red and black wires to the gpio header pins four and six as indicated below so the raspberry pi has this cool um gpio interface where you can buy lots of different raspberry pi accessories to plug into here and i guess a few of these are power and in the guide it's showing us we need to hook the black and red wires up to there so we will do that now which one is which here [Music] okay we're gonna assume that uh this is we're gonna assume that uh based upon the letters that uh this is the bottom so that means the that means the red goes in let me do this over here the red goes in the top left but one over so plug the red one in here and then the black one goes right next to it so we'll put that in here so that should power our fan let's see so let's put the fan in the case here now which way does the fan blow that's a good question i don't know okay let's put it okay i think the fan must blow that way because the wires come out the bottom here so we'll put it in like this okay so we've just kind of lightly placed the fan there and now can i do this okay great now we'll put on the outer edge case great that fits on and now we will try to place the top part okay awesome see if that fits on great there we go okay so it looks like it's put together but uh we'll see if this works so what we have now is i have the micro sd card and it comes with the the this kind of kit version comes with um i think noobs on it which is kind of an easy to get started interface but um in today's video we're going to actually use this raspberry pi as a headless device i'm not going to plug it into hdmi or anything like that so we're going to access everything remotely and i'm going to install this as if this sd card we're just blank we're gonna completely right over this so let me place this to the side for now place this guide to the side and uh i'm gonna switch over to my computer so that we can prepare this sd card here so let me do that one second let me get switched over here okay um back on the computer so one really awesome utility that the raspberry pi group has come up with is this raspberry pi imager and you can download this from the raspberry pi website and what it lets you do is choose an operating system that you want to load onto an sd card so i'm going to load on ubuntu ubuntu server 64-bit edition because i had tried this on my other raspberry pi and i i i could only use the 32-bit version because i had a raspberry pi 2 before um and so i'm going to use the 64-bit version this time and try that out on this raspberry pi 4. so i'm going to select ubuntu server 64-bit server arm 64. that sounds good um i won't use lts i'll just go right here so i've selected that and now what i'm going to do is i have this sd reader this happens to be an anchor one and i'm just gonna plug my micro sd card in there and plug it into my computer so let's plug that in it should recognize it choose an sd card here it is here i'm just going to double check my server selection so 64-bit server been to server arm 64. great so we'll hit right yes i want to continue uh type in my password here cut over to myself okay so it is writing to the card and now we'll just wait a bit so i have the raspberry pi uh here and let me switch over again uh to the camera so i have a power i don't know if you can see it i have power and ethernet ready to go you can set up wi-fi on this i'm not going to run through that today but there are plenty of guides online to do that so i'm just going to use ethernet and usbc power with this because this is powered from usbc and get going so we're about halfway done riding and then we'll boot it up to see if it works let me check the stream here while we're waiting okay looking good two-thirds the way done great so what i'm going to do is i'm going to take when this is done i'm going to take out the sd card plug it in here plug it into power and ethernet and i have on another computer to the side here i have my internet router uh interface pulled up that way it's just a really easy way to find out what the ip address of this thing is there are a few different command line tools that you can use to find out what your dhcp ip address that gets assigned to this box will be i'm not very proficient in those i don't know them offhand so i'm just going to use my router's interface and look at the devices that way so looks like it's written to the card it's verifying now so we should be able to go here pretty shortly now one cool thing that um i've found before let me see if i can let's see one cool thing that i'm going to get running on this device is instead of having an ip address to memorize all the time there's this really cool thing that i found called uh avahi avaha and it allows you to have a friendly host name that you can use on your local network so for instance i think i'll make this one devserver.local and that way i can refer to everything within my local network as devserver.local and that'll be much easier than having to memorize this ip address so let's actually take a look at that and let's look at this so here it is here i was looking for the official instructions okay um i'm just gonna hide that for now okay awesome so the sd card has been written so i'm gonna hit continue uh it's already been ejected for me it looks like here so i'm just gonna unplug it and i'm now going to take that out and plug it here into the back of the raspberry pi so we will stick this in see which way it goes not that way ah that doesn't quite seem right either although i can't tell my other one kind of had a bounce to it so i can't tell if this is right or not see what the other one is i have my old raspberry pi here okay it had the color up okay we'll try this so now i'm going to plug in power i hear the fan and i'm going to plug in ethernet and i see lights so we have power that's a start okay well let me pull up my router page i'm going to do that on a different computer i don't want to show my router live here um so let me clear and rescan here looking for looking for a device i think i see the one here oh gosh there's a lot of devices oh goodness okay i'm looking for my device here and let's pull up item and see if we can ssh into these so i'm going to quit this raspberry pi imager so what i should be able to do is ssh into ubuntu now if this has properly booted up and this way um we can see if this is working so uh i believe the default username and password is ubuntu and ubuntu so we will try this out i have like maybe one or two devices on my router page i think this might be um so let's see let's see which one this is okay let's do uh ssh let me increase my font size here ssh ubuntu at 192.168.1.88 okay that's not it let me try this one might be it let me try 104. that's interesting okay well okay so this could be a couple of things going wrong here either my raspberry pi isn't booting um or uh or i don't have the right ip addresses here it definitely should have booted up fast enough for us to be able to see it now so i think what i'm going to do is real fast just to prove that this is booting or not i am going to plug in the hdmi cable just to see if we can see a screen and see if anything comes up so hang tight with me just a little bit i'm gonna go behind the camera here oh actually i can't the cable i need is plugged into my camera so i'm not going to do that let me try i'll see that one timed out let me look at my list again here just to make sure okay 88 oh oh oh here it is i found it okay i'm using the wrong ip address 111. there we go okay okay i just uh had missed this in the router list that i was looking at so maybe maybe it would have been better to use the command line utilities to find this anyway okay so i'm using the username ubuntu and i'm pretty sure the default password is ubuntu great okay we're in so that means the raspberry pi is working um everything is hooked up appropriately uh we have power we have ethernet the light came on it's connected to the network by dhcp so this might be the point where you could configure wi-fi if you wanted so that you could unplug the ethernet cable and put this anywhere i'm not going to do that in this video but there are tons of great guides online for how to do that so we're just going to use ethernet for now it wants me to change the password so it says current password so the current password is ubuntu i'll type in a new password and there we go awesome so we so far have a running raspberry pi 4. that is great i'm going to check the disk space because i'm interested in that um so we have interesting okay all right so the first thing we're going to do is we're going to update and upgrade the system just to make sure that we're running the latest of the currently installed packages so i'll do a sudo apt update and a sudo apt upgrade oh somehow i got disconnected i'm back on my local host i don't know how that happened okay oh that makes more sense as to why the disk space uh wasn't making sense to me maybe it disconnected me and i didn't notice after we changed passwords that's probably what happened okay now we're back here now let me check the disk space okay this makes a lot more sense to me so we have we have available 26 gigs on our main uh volume great now let me do a sudo apt update and sudo apt upgrade to get make sure all the packages are up to date so right after that i do want to get this um avahi thing figured out uh i'm gonna go to some note old notes that i had for setting up a prior raspberry pi so i can see exactly which package i installed okay great okay yes i will use more disk space i could have put a dash y in those commands to skip that question i'm glad i just had the wrong ip address earlier okay so this is downloading and installing upgrading all of the existing packages we have on here the next step will be like i said we're going to install um avahi the aldehyde daemon so that i can reference this by a nice friendly dns name on my local network instead of an ip address and then we'll move on to installing docker while that's going let's pull up the docker instructions me let's see i think i just want this is not what i did the other day hmm i honestly don't know if docker i guess docker engine is the okay i guess docker engine is the main package i don't know that i even knew that let's see so i'll just follow the official instructions here okay we are still updating packages in the background here we'll put that to the side the fan is a little louder than i uh was anticipating i could try not using the fan and seeing if it overheats or not but it has a little bit of a hum to it here okay almost done with the updates and then we'll move on i did install docker the other day on my raspberry pi 2 that i have here and now that i don't really remember how i did that because i didn't did not go through these steps here um i would have definitely remembered that so [Music] i'm not confident that this is [Music] what i'm trying to do here but it is pretty clear we will move on to after installing docker also installing docker compose okay well we will follow the official instructions for ubuntu here that sounds like a good idea almost done c [Music] do we might have to reboot the raspberry pi after this so we'll see finishing up maybe okay there we go looks great okay so let us um [Music] let's see so according to the official instructions here it wants us to remove old versions of docker in case they're installed so i will go ahead and do this i doubt that any of these are installed but we'll see okay sounds good um and now we will set up the repository so we we have already run update so that's fine so now we want to run these other items and then we'll add docker's official gpg key yeah i definitely didn't do this the other day i have no i i don't know how to install docker the other day so we will add the key this is the official website wearing app key is deprecated okay that's fine verify that you have a key with the fingerprint okay we do have this key okay that looks good okay we are running on arm 64 here so let's do this one okay now let's okay so that was all setting up the repository that we needed so now we're going to actually install docker engine itself it wants us to run update again perhaps that's because we have a new repository let's see okay that's done so now we'll install docker container engine cli and containered uh to be honest i haven't used container before i'm not sure what that is i'll figure that out later so what we're doing here is i'm getting docker installed and then i'm going to get docker compose installed because those will be prerequisites for being able to run my dev setup on this raspberry pi once this is all set up we're we'll kind of switch gears and open up vs code and get remote development set up here with vs code oh you know what i didn't do i didn't set up the um avahi dna friendly dns name we'll do that too okay so those all installed let's see to install specific version i don't really care about a specific version okay that doesn't matter as much to me okay so now we'll verify that it's running uh so we will pseudo doctor docker run hello world we're pulling that's a good sign hello from docker this message shows that your installation appears to be working correctly excellent okay there we go so we have docker let's move on to now docker compose um so i will just pull up once again the official instructions here and docker compose is uh i believe written in python so a lot of these instructions will have to do with uh making sure your python setup is good um and they they have a shell script that you can run and that's what i'm going to do here to make things easy let's see for alpine okay so we will try docker compose um permission denied that's expected here is a command you can run to add the execute permission to what we just downloaded um i guess that actually wasn't a this wasn't a uh shell script this was actually downloading docker compose itself so let's check the version command not found okay we might have to do that too let's try docker compose version again command not bound okay um let's see let's uh list out what's in our user local bin uh we do have docker compose it looks like a tiny file i have a hunch that that may be a whole lot of nothing not found okay so what we did earlier was we downloaded a file uh from github and that was a big 404 so i'm trying to run this file and it's really just a text file that says not found so i'm going to delete what we downloaded here yes and i think what we'll have to do is now go over to alternative install options and that's where we're actually going to use python and pip to install docker compose so i'm going to i probably don't have uh all of the python dependencies installed since this is a brand new version so i'm going to make sure that i have everything i need so compose can be installed from high pi using pip see the virtual m tutorial to get started okay so let's see if we have python i kind of doubt that but we'll see we don't okay so we have we can install python or python uh three python is python three command python now i know there's this whole big confusion between python 2 and python 3. and i don't do this enough to know if i do an apt-install python exactly which one i'm going to get but we're going to we're going to try that i know you can do apt-install python3 um okay so this says python is python 2. that's definitely not what we want so i'm going to command a control c out of this and we're going to sudo apt install python3 and also pip3 um that is apparently not it okay let's get python going let's see python 3 set to manually install okay so we have python do we have tip tree okay there we go this is what we need okay so pip is the package manager for python and that is how we'll install docker compose here in case you haven't noticed i am no linux expert so uh be lots of googling in this video okay so getting closer so um if you are just tuning in now what we have done is we have set up this uh raspberry pi 4 here uh this is as far as i can pull it over this is a raspberry pi 4 that i just got today it's 8 gigs of ram and what i'm trying to do is get docker and docker compose installed on this so that i can continue development now that i have this nice shiny new mac m1 macbook pro where docker for mac is still not yet compatible with it so my goal is to get this raspberry pi going for my docker development and use vs code the vs code remote development extension to be able to develop remotely on my mac but using the raspberry pi okay so pip is installed let's let's see they want me to set up a virtual environment that sounds nice but i'm not sure that i'm going to go through that okay so pip is now we have pip running yay pip is now installing docker compose once this is done i still don't want to forget to install the avahi daemon and uh get that going and then we'll switch over to vs code and see if we can get the vs code server set up on here as well hmm another thing i looked into um since since i got this m1 is could i use github code spaces to do development while i'm waiting on docker for mac to be compatible with the m1 um because i do i was granted access to github code spaces but as far as i know you can't have multiple github repos in a single code space at least not right now um and the main project that i'm always working on uh we use multiple repos uh together and so that's kind of why i need something a bit more customizable plus this raspberry pi raspberry pi will be here local on my local network so it'll be super fast and it's fun what are you doing on a sunday oh i'm watching someone on youtube install packages live building while we're waiting on this to build i will plug so this this kit that i bought i bought this kit on amazon and this is the try not to show my address here this is the this is the conicate and it's super handy it comes with a case a power supply um the fans the heat sinks comes with sd card it even comes with um a micro sd card reader in case you don't have one of those um i happen to already have one and it even comes with this this is kind of interesting it comes with this uh push button i guess you can i guess this is something you can use the raspberry pi to program some sort of on off switch i'm not sure oh maybe this is for power on and off maybe but this kit is pretty cool and it comes with everything you need i already have a couple of older raspberry pies and i was just going to buy the board alone and use the old cases but you can't do that because the old raspberry pi's have a real hdmi port on them but the news raz the new raspberry pi's use micro hdmi and they actually have two outputs um so the case is uh the same size but the port layout is different so let's see how our build is going still building packages here my metric of success today will be can i use um can i use vs code remote development to pull in a repo that i've already started uh kind of is a very base of a future project i want to work on and can i get docker booted up on that and loading the web interface at all what i'm the this very basic setup that i've uh started in this repo is an apollo server so i'm hoping to see if i can load apollo playground and if that works then this is this is a success that would be awesome okay so this has theoretically installed docker compose uh let's see there we go okay awesome so we have docker installed we have docker compose installed now one side tour is we're going to install um the avahide daemon so i'm going to do a pseudo apt install avahi demon and what this will do is this will use whatever host name you have set up in etsy host name and that will be whatever that name is dot local will be your dns name that you can use on your local network uh i'm interested to see if this comes with a host name uh it comes with ubuntu so you could do ubuntu.local um i'm gonna change this uh so i'm gonna change this i might have to pseudo that not sure oh my i haven't gotten my meta keys to work on here yet okay so this is going to be i'm going to change this to dev server is going to be my name okay so now my host name is dev server so what i should be able to do is with the avahide daemon running is ping this as devserver.local on my network on my local network so let me open up a new pane here in item so i'm no longer on the raspberry pi here the raspberry pi is the top one the bottom one is my local machine here so let me see if i can ping dev server dot local i i don't know if this will work immediately because i changed the etsy host name after i installed avahai so uh i'm wondering if there is a reboot yeah here's a reload oh hi damon do a reload okay so we'll give this just a second and see if we can ping if not we'll keep using that p address for now but this would be nice um let me see if okay we do have the daemon is running um so that's good oh look it says ubuntu.local um i might actually restart the whole thing here uh because i would like to figure this out so i'm going to do a pseudo reboot this is not my mac this is raspberry pi okay so i'm going to do a pseudo reboot uh the raspberry pi uh is rebooting right now i did change the etsy host name uh i don't know if a reboot's required after that after that or if there's another way to do it but uh i'm not gonna sit here and figure that out live so we're gonna reboot this and see if it comes up with our new host name after the reboot so let me do another ping here and see if i can ping devserver.local i don't know how long this takes to boot up but probably not that long um let me let me try sshing again using the ip address okay so this is booted now um let me do another h-top and check on check to see what's running here so okay we do have the autohide daemon running devserver.local so let's see there we go okay awesome so what this means is i don't have to memorize this ip address i don't have to worry about it changing on my local network from dhcp i can always reference this machine on my network as devserver.local so i think i think that we have everything that we need on the raspberry pi itself set up we have um docker we have docker compose uh we have the avajai daemon running so we have a nice dns name now let's switch gears over into vs code and use the raspberry pi as a remote dev server so i'm going to just switch spaces here and pull up vs code and what you can do is this little um this little connection area down here says open a new remote window actually i'm going to do command shift p and we're going to say uh remote now i think you use this down here oh remote remote ssh that's what it is yeah remote ssh so that's what we're going to use now in order to get this option in vs code what you will have to do is go to the extensions and search for remote development and this is a microsoft supported and maintained extension actually this is an extension pack so if you install the remote development extension pack you'll get these three extensions here which will allow you to use vs code but you're running everything on a remote machine so once you have that installed you should get this little icon in the bottom left in order to connect to another machine so i'm going to use that and i'm going to connect the current window to host and i set up one earlier this was my raspberry pi 2 that i was setting up that's why i wanted to choose a different dns name so i'm going to add a new ssh host and i will just follow their prompt here so i'll do ssh ubuntu at dev server dot local and we will save this in my users config host added so now we'll say i'll run this through fresh so we'll go to connect current window to host we'll connect it to dev server and we'll see if this works we'll continue we'll enter our password um the other thing i could do is set up ssh keys so i don't have to enter my password every time i won't do that today but that's probably something i would want to do so i don't have to enter my password every time it doesn't sound like a huge deal but uh especially if you're running on a laptop and you're connecting and disconnecting then that could be a bigger deal okay this is a good sign so we have dev server running so what does this mean what this means is now in vs code it's operating as if it were operating on the raspberry pi so if i go to open a file i'm not going to see my max file system here i'm going to instead see the files on the raspberry pi so if i go to open folder here um this is my home directory for the ubuntu user this is not my max directory so that's pretty cool so what i'm going to do is i'm going to go clone one of my projects um like i said this is a oops i hit okay to open a file that's that's not what i want um you know what i'm gonna close out of that let me connect again okay um so i have this repository um set up for a future project that i want to work on and it has a docker compose setup and so i'm going to use vs code to clone that down from github it's going to clone it onto the raspberry pi for me and then we will try to run docker compose and boot it up and see if it's working so let's go to our repository so i'm going to use the built-in github vs code integration to say clone repository clone from github and i'm going to choose one of my repos that i'm working on so i'm going to clone this down i want to clone it down into i'm going to make a code directory path does not exist okay one second let me make that path exist so i'm going to make a code directory here within the home directory of the ubuntu user so let's try that again oop clown from europe okay i want to clone it into my code directory so this is now do you want to open the clone repository yes i do do you want to install the recommended extensions show recommendations yes i have this so this is another thing is if you're using any extensions uh you may have to install them onto the remote server that you're using so that's what's this that's what this is saying here so i had it installed locally but not on the remote server by the way since we're since we're doing all these remote things let me pull up h top again and you can see that what we have done by connecting to this raspberry pi via vs code is vs code has ins on its own without us having to really do anything it has installed some sort of vs code server that is now running on this raspberry pi to support the the back and forth between our client which is my mac m1 so let me go to my repository here it looks like this has been pulled down so that's great um so let me open up docker compose here so what this application uh is composed of is we have a postgres server which is just using the standard postgres image i'm on postgres 11 right now and then we have a backend service which is my code that i have in here it depends on postgres and it connects to the database so if all goes according to plan here what i should be able to do is boot up docker compose and have it run on the raspberry pi so um i could use the docker um i could use the docker extension within vs code but i think i'm just going to pull up a terminal and you can see here that when i pull up the terminal this is not my mac terminal this is once again this is the dev server this is my raspberry pi and so i'm just gonna do a docker compose up and see what happens okay failures let me let me increase the file size here what happened okay permission denied blah blah blah that's interesting okay i'm going to try to do this in my other ssh window and go to that directory because this is now cloned on this directory and let me do a docker compose up and see what happens here um same thing here so this is this is still my phone is blowing up over here this is still giving me issues i'm not sure what this error is just for kicks i'm gonna do a pseudo docker compose up um i didn't end up doing the recommend okay that's what happened i didn't end up doing the recommended uh using virtual m over here um i'm just not as familiar with that because i don't work in python all the time so it's probably that i what this probably means is that i need to go through this virtual m tutorial and install it this way because i can see if you are using virtualenv you don't use sudo but if you aren't you do have to use sudo okay so this is now pulling down i'm i'm going to control c out of this actually because i want to switch back to vs code so we're just going to use sudo for now but uh this means that i probably need to look into virtual imp not pip docker compose up okay here we go so uh it in in my previous window it downloaded postgres now it is building my uh app that i just cloned down from github it's running through the docker file that i have set up here uh i'll just show you that so if i pull up my docker file uh i have a fairly basic docker file here i'm pulling from the official node image i've created a working directory i'm copying in my yarn and package.json files i'm doing a yarn install to install the dependencies this project uses prisma so i'm also pulling in the prisma schema in generating the prisma client so that i can connect to the database and then finally it exposes the ports it needs and runs a command to start the server so we're looking good so far it has installed all the dependencies now this is the step or this is one of the steps that i had failed at on my raspberry pi 2 is because the prisma dependencies weren't compatible with the raspberry pi 2 which is uh older it's i think it's arm v7 i saw whereas this one is arm v8 and it's not 64 bit either so i had a couple of different issues along the way trying to do the same setup on my raspberry pi 2 which is why i got the four so everything all the packages built so that's a great sign so i'm i'm further than i was on my raspberry pi 2. um so this is it'll take a second here to finalize the docker image and then we'll see if that boots up with compose um let me check my phone real fast okay we're good um once this boots up will compose then the question will be how do we actually visit uh the website that this may boot up what we're going to do is we're going to boot up the apollo graphql playground and if that loads or golden um that means this is a success uh what vs code remote development has is let's see okay we have an error let's see here unknown system error queer engine limits okay this may be another issue specific to this project um and that is uh i think there are since this is an arm-based processor i think um there are some further steps i would need to take to get prisma compatible with arm i did some googling on that prior to this it is pretty extensive it's doable but it's extensive i don't think i'm going to do that in this video so what i'm going to do instead here is i'm going to modify this slightly just to see if i can boot up node at all if i can boot this up at all then i'll be pretty happy and i can after this go get prisma compiling and set up with the arm processor so i'm going to just actually comment out um my prisma steps in my docker file and i'm going to create a new server here so let me do i'm going to do a yarn install express i'm just going to do a oh i didn't even install yarn yet that's interesting how funny okay so i'm going to do a uh if i were on my mac i would do a brew install yarn uh yarn get started install they recommend npm installing yarn okay so what i might do then is install node ubuntu uh what i might do then is i have to install node.js okay let's just do that here okay so we're going to install node so that we can get npm so that we can install yarn that's what we're doing npm install global yarn okay so npm install global yarn okay we have node it's node version 12. that's old um the current long-term support version of node as of this recording is 14 and the newest version is 15. um so node 12 is old so maybe i rushed through this a bit it might not matter that i'm running node 12. okay it does want me to do pseudo after install npm okay so let me do that we have a tree of dependencies here so we're going to install node and npm so we can install yarn so that i can add just a super simple express over here and boot it up inside a running container inside docker compose and if that's good then i'm happy i can go figure out prisma compilation later because i know if you want to custom compile prisma that involves getting rust installed and going from there so i'm just not going to do that in this video a little outside of scope i just want to know that i can run docker compose remotely on this raspberry pi through vs code so apparently npm has lots of dependencies here so we're going to do all sorts of things overall though we've been on there i've been on air for an hour and 15 minutes now and so i have to say not that's not so bad for getting this up and running from literally opening the box putting it together booting it up um getting ubuntu copied and flashed onto the sd card getting it set up installing packages failing a few times along the way getting docker installed getting darker compose connecting to it that's not so bad by the way if you use github code spaces um it has a very similar interface to this indicator down here in the bottom left so i'm curious as to if the vs code remote development is kind of your own version of github code spaces but you're using your own server via ssh instead of the official github code spaces servers might be not sure okay so still installing all sorts of node packages what i'll do in the meantime is uh i still need yarn but what i'll do in the meantime is i'm just going to create a test server file just in plain old javascript and what we'll do is i'm not even going to mess with imports we're going to do super super super basic um so i will do i'll import express and then we will make an app and then we'll do app.get and we'll get the root request response and we'll respond with a send a hello docker and then add listen we'll call it port 3000 and we'll go so that's my very simple server where if we do a get request of at the root uh we should get text back saying hello docker okay so npm has finished installing down below let's use that to install yarn globally yarn is probably overkill for this but we're gonna do this anyway okay let's see if i have yarn um i might have to close the terminal and reopen it okay i'm not gonna mess with yarn then we're gonna do an npm install express it says i can get yarn through this command test package but i'm not sure what that is i need to google that further um so we've installed yarn can i just outside of docker can i boot this and run it let's see so let's see if we can do our node test server it did recognize a port so i'm going to open this up in a browser now i expect this to succeed but let's not get excited yet because this isn't running in docker yet so if this succeeds okay that's excellent so this is hello docker it's forwarding the port vs code is forwarding the port from raspberry pi locally here and i can see that is if it were running on my local machine now this says hello docker that we're not actually looking at docker yet this is just node running on the raspberry pi that's cool but not what we want what we want is for this to run inside of docker so i have modified my docker development file here we're going to skip over the prisma stuff um and what i want the command to be is we're just going to run node uh test server and i'm going to expose port 3000 so if this builds and runs in docker compose and we can re-pull up that page in fact i'm going to close this then this will be a success so let's do a docker compose up no oh i need to do sudo again again i don't want to do sudo um but i think i need to set up the virtual environments for pip which i skipped over so after this video i'm going to go back and set that up now this is installing okay so i'm going to have a problem here this is installing uh well that may not be so bad because it copied in patch package.json which should have it does have express in it so that should install okay so this is what this is doing is it's re-running through my docker development file that i have here um because i made changes to it and it recognized that so i'm now skipping over the prisma steps i'm exposing a different port and i'm changing command so anytime you change something in the docker development file it will rerun the first step that changed in all previous steps after that so it successfully installed all of the npm dependencies and built the packages and we did get that far before but we ended up failing when trying to generate my prisma client so that's something i would go figure out after this video is how to build prisma on the arm processor of the raspberry pi but for now we're not going to do that we just want to see if we can get an express server running so it will take a little bit here to finalize this image and if that works then we can then hopefully it will go right into booting up um it'll actually it will boot up the database server as well as just our little test server here in node okay so we're getting farther so it's creating the database server which we're not using the database right now for a test but it's doing it and it's creating the backend service which should be our node service here for test server um i would bet that let's see if i think that is this the port forwarding tab i think there's a there was a port forwarding to oh here's ford of pork okay so we'll see if um oh you know what since i changed that port uh i may have to go make a docker compose configuration change because i have this set to i have port mapping here for the app i've been working on set up to 5192.29 um well i'm going to add in port 3000 here and you know what i need to do is i don't have any console statements to say that i've booted up the server so we're going to shut this down we've gotten farther i'm going to also expose uh i'm going to expose port 3000 here and i'm going to in here there's a call back to listen uh hostname oh let me go ahead and do zero dot you have to do that for docker most of the time and i'm going to do a call back um to say node server booted so we've done all of those things i have a syntax error which i didn't spot that's a good sign though okay so the node server booted uh i didn't get the automatic port forwarding uh prompt and vs code which leaves me a little wary um but let's see i've gone ahead and manually put it in here let's see hey there it is okay now that's the same one that showed up earlier so i'm gonna go ahead and change this to like hello docker so i'm going to change that and we're going to make sure this actually says what we want okay let me open that again and there's hello docker compose awesome okay so i'm so happy so what this means is i have my apple m1 macbook pro which is not yet compatible with docker uh the docker folks are working on it i hope that apple's helping them um what the back story is on that by the way is at wwdc when apple released the dev version dev machines so that companies could start getting all their apps compatible with the m1 what i read about it is that the dev machines didn't yet have the virtualization um tech in those m1 chips it wasn't released yet and so docker really hasn't been able to work on it all along that's kind of my understanding so as the public has been getting these m1 machines that's kind of where we've started that's that's why it seems a little bit behind but what this means is i have a brand new apple in one machine it's not compatible with docker yet however i can use vs code and the remote development extensions to connect remotely to this uh raspberry pi this uh raspberry pi here and develop like normal so as long as i have this pie with me um which thanks to the pandemic i'm pretty much always in the same place anyway as long as i have this pie with me then it will be very easy to continue my development using docker just as if i were before because i can do everything here in vs code pulling down my repositories getting docker compose set up i can completely customize this machine to however i need it to be and continue on development so that's pretty cool another side benefit of this even if i didn't have an m1 machine or even win docker for mac becomes compatible with m1 um what this means is that my the horsepower that it's taking to run my development servers has now been offloaded to the raspberry pi and so this may be something i continue even after docker for mac becomes available and compatible is to run this on the raspberry pi just simply to offload the resources from my main machine here so that would be a really nice benefit of this as well but uh to sum up what we've done is i have the apple m1 machine um i purchased and just arrived today this raspberry pi uh four i got the eight gigabyte one but it comes in two four and eight gigabytes um this this kind of kit that i bought off amazon i think it was 130 dollars comes with everything you need um no ethernet cable uh but it comes with everything else that you need we installed ubuntu on it using the raspberry pi imager utility that you can download from the raspberry pi website we installed ubuntu 20 64-bit version then we got our dependencies of docker and docker compose installed with a little bit of python along the way and i used the avaha daemon to be able to reference this machine with a friendly dns name on my local network instead of having to mess with the ip address changing on me and now with vs code i have the remote development extension installed where i was able to connect with this raspberry pi server and pull in my repos and run docker compose here in vs code so i think that's a success i'm very happy with this i think this will be awesome for developing so what will i do from here so what i'll do from here is i want to figure out how to run docker compose without using sudo each time so i think that has to do with setting up a virtual m for um pip so i'm going to go research that a bit more next up the projects that i do use in docker use prisma because i'm a big prisma fan for connecting with databases in node in javascript and typescript um and i think that there is some custom compilation that i'm going to have to do with that i started doing that on my raspberry pi 2 um so i know that that's available but i ended up failing because it wasn't compatible with this but i'll probably have to go install rust and get prisma compiling and also figure out um yarn figure out uh why yarn wasn't working but i have docker compose booted no test servers running port forwarding's working and i was able to pull up um this hello docker compose so pretty happy with that not too bad an hour and 32 minutes hour and a half well thanks for tuning in uh i hope you found this useful or entertaining or fun uh i'm pretty excited about getting this set up i'm even more excited that uh docker development isn't going to hold me back from using my new m1 machine and we'll go from here if you liked this video let me know leave a comment leave me a like if you like and hope you have a great day and i'll see you next time
Info
Channel: Kevin Wade
Views: 583
Rating: undefined out of 5
Keywords: docker, apple m1, raspberry pi
Id: xZNT1HfwGeQ
Channel Id: undefined
Length: 92min 44sec (5564 seconds)
Published: Mon Dec 14 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.