Skip to content

Instructions for setting up basic Ubuntu development environment for App Academy curriculum

Notifications You must be signed in to change notification settings

9ziggy9/aa_ubuntu_build

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 

Repository files navigation

Ziggy’s Ubuntu Build for AppAcademy

This (hopefully) short tutorial is intended as a guide to setting up a simple development environment in Ubuntu Linux compatible with AppAcademy’s curriculum. THIS GUIDE IS OFFERED WITH ABSOLUTELY ZERO WARRANTY AND I AM NOT RESPONSIBLE FOR ANYTHING YOU BRICK/DESTROY/ANNIHILATE/RENDER UNUSABLE. That said, if you find yourself in trouble, feel free to submit an issue to this repo and I’ll try to get back to you in a timely manner. :) Here is the accompanying video: https://www.youtube.com/watch?v=pkZ2l-KLznA

Creating Bootable Installation Media

In Windows, acquire “balenaEtcher” and the non-LTS Ubuntu installation image. balenaEtcher is extremely easy to use, simply provide Ubuntu ISO image and desired drive to flash and voila. WARNING: whenever flashing any sort of storage media, be sure that it is the one you intend to target. That is, be absolutely certain that you have provided the flask drive path and not your filesystem!

Links

BIOS configuration and BOOT priorities

Entering BIOS configuration

Now that you have your bootable disk media, you will want to reboot your machine and enter BIOS configuration. To do this on a typical machine, one interrupts the boot process by hitting their associated BIOS setup key before system startup of operating system can be reached. Sometimes we do not know what key is necessary to enter BIOS. To solve this:

The realistic way:

As system is starting, as soon as you see the logo screen (DELL, ASUS, HP, etc…) start repeatedly pressing your F keys. If you’ve mashed sufficiently, you should be directed to a prompt asking you to enter BIOS setup, or you may simply be directed there.

The professional way:

Given your machine model/make, look up the corresponding BIOS configuration key. Typical BIOS configuration keys are:

  • Esc
  • F2, F12, F8, etc…

Setting BOOT priorities

Now that you are in your BIOS configuration, you will want to navigate to a section which details the order in which disks are booted in. Typically, BIOS utilities have tabs at the top and one in particular labeled “BOOT”. What you should see is an ordered list, with your HDD at slot 1. If you look at the bottom of the boot menu, you should see some indication of how to promote media in this list. Typically this is done with -/+. Navigate to your installation media in the ordered list, (i.e. the USB flash drive), then promote it to the top of the list. Look for the save/exit command. Typically it is F9. Confirm the changes and upon reboot, if all has gone well, you should be booted into the Ubuntu installation! If this seems confusing or these directions do not quite match with the reality of your system, you may have to independently research a solution. I am providing the link to this YouTube video to help you better visualize what this process looks like. If you are at all confused, please reference this before moving forward!

SECURE BOOT WARNING and general troubleshooting

Many newer machines which target the Windows operating system have an additional UEFI feature called secure boot, this feature can at times interfere with the Linux bootstrapping process. If you find yourself unable to boot into the Linux installation environment, the first thing you should try is disabling this feature in BIOS. You should be able to find it trivially, but there are also resources online for most hardware if you care to look.

Ubuntu Installation

Ubuntu Linux is EXTREMELY easy to install. For the most part, this process is just following prompts. When prompted with the GRUB boot manager, simply select first option with enter. You should be directed to installation page, select “Install Ubuntu” and proceed. A few notes as you are going through this process:

  • since we are not attempting a dual-booted system, after this installation process is complete, Windows will no longer exist on your system and all data on the disk with be irrevocably destroyed. I AM NOT RESPONSIBLE FOR YOUR LOST DATA :)
  • I highly recommend choosing the “Install third-party software for graphics and Wi-Fi hardware and additional media formats” option in the Updates and other software menu, as this will ensure any proprietary drivers needed for your system will be included.
  • After you have selected installation type, i.e. Erase disk and install Ubuntu and hit “Install Now”, there is no turning back. So think very carefully before your proceed at this juncture.

Ubuntu configuration

After you have removed your installation media and rebooted, you will probably want to re-enter your BIOS and return BOOT priorities to their previous setting. Nevertheless, upon system boot, you should now be directed to your fresh Ubuntu system. Enter your password and we now get to the real stuff.

Package Management Notes

You will initially be prompted with a GUI interface which will allow you to select packages for installation. I am going to STRONGLY recommend that you do NOT use this method of package management. We are developers and to avoid the use of the robust Linux command line in favor of something geared towards non-developers is silly. At this moment, I should explain a little bit about package management in Ubuntu.

Package Managers

There are many ways to acquire software on Ubuntu. I will give a brief overview of the core utilities.

  • apt is the main package management system of not only Ubuntu, but all Debian derivatives. Typical open source software which is developed with linux in mind will exist in the Ubuntu repositories and will be accessible with a simple
    sudo apt install <package_name>
        
  • snaps are a containerized installation method which is typically used in cases where the software in question is targetting proprietary and/or more mainstream operating systems. Snaps are useful in cases where changes in dependencies (i.e. dynamic linking of systems libraries) have the potential to break Linux compatibility. Essentially the way they work is that all dependencies needed in order to provide a stable package are bundled together with the target software itself within a container. This will increase the space footprint of the given software, but will ensure that system upgrades will NOT break any dependencies and render the software unusable. Think of softwares like VSCode, zoom, slack, etc… If the software is not intended as FOSS, you most likely will be performing a snap installation. Snap packages are typically installed via
    sudo snap install <package_name>
        

    although at current time, so called “classic” confinement is often needed. We do this by simply supplying the “classic” flag

    sudo snap install --classic <package_name>
        
  • dpkg is the core package installation utility of Debian and it’s derivatives, there be dragons here. Whenever encountering installation instructions that recommend the usage of dpkg on provided .deb packages, we should EXERCISE EXTREME CAUTION. The reason being, Ubuntu and other distributions that lean heavily on apt do so to avoid what is known as dependency hell, a situation one can find themself in when they look to manually provide software support. For the most part, stay away from this unless you know precisely what you are doing and have an intimate knowledge of the versioning of your system software.
  • other methods are installations which involve the use of direct compilation, provided build scripts, or other means which involve the raw targeting of bin directories. Typically, we will encounter these types of installations as instructions from a git repository or in the building of our own software. 99% of the time, when we want some software which is not included in official repositories, the given application’s relevant installation instructions will be included in their repository. At some point in this tutorial, we will see an example of this in the installation of some additional zsh features. It should be noted that the raw management of dependencies as with dpkg can present issues with such softwares but more often than not, we seek to install lightweight freestanding software in this fashion.

Fresh System Update

The provided Ubuntu image is most likely not 100% up to date, let’s take this opportunity to run our first apt command to perform a full system update and reboot! Open a terminal with ctrl-alt-t and run the following commands:

sudo apt update
sudo reboot

Installing VSCode, zoom, slack via snaps

Now that we’ve performed a system update, let’s begin installing our more proprietary minded software via snaps.

sudo snap install --classic code
sudo snap install zoom-client
sudo snap installl slack

Installing git, zsh, curl via apt

We now install git and zsh as our user shell, as I personally cannot live without it. Note the use of apt here, as these are widely loved and maintained FOSS (free and open source software). We can inline multiple packages if we’d like. We’ll also need curl in the future.

sudo apt install git zsh curl

To set our default user shell to zsh, we run

which zsh

to confirm the path to actual zsh binary (/usr/bin/zsh in our case) and then run

chsh -s /usr/bin/zsh

we quickly logout and log back in, and when opening a terminal we will be prompted with zsh initial config, just hit 2 for a simple config. We can always change this later.

Quick digression to install bloat!

There are some absolute MONEY zsh utilities I would like to install at this juncture. You can skip this if you’d like, but once you start using these things you can’t go back. This will also give us the opportunity to demonstrate an example of our other methods of installation.

oh-my-zsh

This is an extensive zsh customization framework, we’ll add it to prettify our console prompt a bit and utilize it’s autocompletion features. If we navigate to the oh-my-zsh github repo, we see installation is trivial. We’ll use the curl method, but first we need curl!

sudo apt install curl

Now we run the recommended curl command;

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Presto, change-o, you now have oh-my-zsh installed. Have a look at themes if you’d like, we’ll go with default at the moment. It is probably important to note that what we just did, piping third-party installation script to sh -c via network is EXTREMELY DANGEROUS. Never, ever, ever do this unless the software in question is reputable and widely used. oh-my-zsh is a Linux community mainstay, so in this case we let it slide.

fzf

This is the most beautiful and indispensible shell utility I am aware of. This tool alone is worth the entirety of the tutorial. fzf DOES exist in the official Ubuntu repository but requires additional configuration to get the feature set I want here. We again consult the fzf github repository and simply run their installation directives.

git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf

this will clone the repository to a hidden directory in home called .fzf, and in this directory is an installation script we run by providing the command

~/.fzf/install

hit y for all prompts! We want all the goodness. To apply the shell configuration changes, we need to source our config file

source ~/.zshrc

BTW, in case you didn’t know, the squiggly line “~” is an alias for the user’s home directory, i.e. /home/ziggy in my case. Now I’m going to blow your mind. Up to this point we have typed in many commands. Suppose we don’t remember one, but we need it again. Hit ctrl-r and start typing what you remember. YOU’RE WELCOME Can’t remember that Heroku command you ran before? ctrl-r, can’t remember some bizarre shell/awk combo you used earlier this week? ctrl-r. Here’s another one to try, say you want to cd into a directory but don’t quite remember it’s path. Type cd, then ctrl-t. OH MY GOD Yeah, I know. You are forever in my debt for showing you this.

Python, NodeJS, Postgres installation

Let’s install our core programming languages and do some minor config.

sudo apt install python pipenv nodejs npm

We should note that we are generally going to be using python 3, so it is somewhat inconvenient to constantly reference python 3 via python3 command. Let’s create a quick alias to fix that.

echo 'alias python="python3"' >> ~/.zshrc
source ~/.zshrc

Now you’ll notice that

python --version

returns python 3.9… something or other. NodeJS should just work out of the box. Let’s move on to installing postgres and configuring it.

sudo apt install postgresql postgresql-contrib

Now that we have postgresql installed, let’s start the service (going forward it should be started by default, but we can always re-run this command if need be.)

sudo systemctl start postgresql.service

Now, postgres by default creates a default postgres user and our current user doesn’t have the permissions that his default user does. So let’s quickly change to that user and create a user associated with our account.

sudo -i -u postgres

Now that we are logged in as postgres user, we can create a new user associated with our primary account.

createuser --interactive

Follow the prompts, provide your user name and give yourself superuser permissions. Then create a DB associated with your username and logout of postgres user.

createdb <your_username>
exit

Voila, you should now be able to access psql shell without issue!

psql
# \q to quit, if you don't remember.

Docker installation (final boss)

This is an Ubuntu specific issue, had we chosen an Arch based distro, or some type of rolling release model, we would not encounter these issues. The Docker app provided by Ubuntu repo is PAINFULLY outdated. To mitigate this, we are going to add the official Docker repo to apt and install the so-called Docker community edition. What follows is somewhat hands on and totally atypical of Ubuntu system management. When in doubt, consult documentation, as I have for this guide. Let’s begin by enabling services that allow apt to use packages over HTTPS.

sudo apt install apt-transport-https ca-certificates curl software-properties-common

Next we add a trust GPG key from the official Docker repo to the apt key chain (you can safely ignore the deprecation warning as of today 04/01/2022).

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

We then point the official Docker repo at apt:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"

Let’s verify that apt now points at the official Docker repo and not Ubuntu’s.

apt-cache policy docker-ce

You should notice in this output that the version table should reference things like

500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages

Finally, we can actually install docker.

sudo apt install docker-ce

let’s verify that Docker is running (it should automatically start going forward)

sudo systemctl status docker

Finally, because many of our future heroku-cli commands and such will involve the assumption that user is privileged to use docker, we will need to add user to the Docker group so that we can run it in the future without sudo.

sudo usermod -aG docker <your_user_name>

reboot and let’s verify docker works:

docker run hello-world

While we’are add it, let’s install Heroku command line too.

sudo snap install --classic heroku

Note when using heroku-cli, we might need to login interactively in the shell, not redirect to webpages. It’s better this way anyways;

heroku login -i

About

Instructions for setting up basic Ubuntu development environment for App Academy curriculum

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published