Starting from:
$25

$19

Containerized Development Environment

Introduction 

C++ is a programming language whose implementation is a compiler.  The high-level source code that you will write this semester will be translated by the compiler into the machine language of your system.  To avoid implementation-dependent issues, our class will be writing and compiling code in a prescribed development environment.
Container setup
    1. Go to Docker Desktop download page at https://www.docker.com/products/docker-desktop and download the installer image for Mac with Apple Chip (also known as Apple Silicon or M1) or Intel depending on your machine.  
        a. You can check the type of processor by navigating to the  Apple menu, (located in the top-left corner of the screen) and selecting "About This Mac".  A window will open.  Inspect it for the processor.  My machine is running an Intel processor as shown in my "About This Mac".

  

    2. Install Docker. 

    3. Launch Docker.  This will place a Docker whale icon in the menu bar (where your clock is).  You can click this icon and select "Dashboard" to launch the Docker interface application.  You will always need to start Docker in order to access your development.


    4. Download https://github.com/cs128-illinois/cs128env-docker-2-student/archive/master.zip. If prompted, enter your GitHub.com username and password.

    5. Extract the folder and rename the extracted folder to cs128env 

    6. Drag and drop your cs128env folder to the location where you would like to conduct your development throughout the semester.   DO NOT COPY AND PASTE THE FILES FROM IT.  MOVE THE WHOLE FOLDER.  You will not be able to move this later.

    7. In the terminal, change the directory (using cd command) into your cs128env folder.  You can do this by writing cd and then dragging and dropping the folder into the terminal window (this should provide it's path).  



Subsequently, click enter.





    8. Execute .helpers/reset-mac.sh from inside your  cs128env folder


ONCE YOU DO THIS ↑, DO NOT MOVE THE LOCATION OF YOUR cs128env FOLDER. 

        a. If .helpers/reset-mac.sh cannot be found, ensure you're in your cs128env folder and have typed the command correctly.  If this is true, return to step-4 and restart from there: we need to ensure you have the latest version of both the container (step-4) and cs128env directory (step-5).

        b. If .helpers/reset-mac.sh does not have permission to execute, run chmod a+x .helpers/reset-mac.sh subsequently chmod a+x .helpers/setup-mac.sh and then re-execute .helpers/reset-mac.sh
 
        c. If and only if you observe "Error response from daemon: Mounts denied" you will need to:
            i. Open the docker dashboard GUI, 


            ii. Click the gears icon 
            iii. Navigate to the "Resources" tab, click "File Sharing"

            iv. Click 
            v. Navigate to your cs128env directory 

            vi. Click "Open"
            vii. And the directory will be added to the list:

            viii. Now click "Apply and Restart" for the changes to go live.  This can take a minute as Docker restarts.
            ix. Execute .helpers/reset-mac.sh from step 8 again.  This time it should succeed.

    9. In a new terminal window, execute
ssh -p 2222 vagrant@127.0.0.1 
typing yes to the prompt about the key and entering vagrant as the password upon request (there is no feedback while entering the password, so you won't see `*` appear as you type): 


        a. Should you observe a "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!" during this process, execute ssh-keygen -R "[127.0.0.1]:2222".

    10. You should now be logged into the virtual environment. Your terminal prompt acknowledges this (vagrant@...): 


    11. Configuring Git in the virtual environment:
        a. Set your username (as your full name). Inside the terminal window connected to your virtual environment, execute the following command:
 git config --global user.name "Mona Lisa"
where Mona Lisa is your name.  For example,

        b. Set your email address (as your Illinois email address).  Inside the terminal window connected to your virtual environment, execute the following command:
git config --global user.email "email@example.com"
where email@example.com is your Illinois email address.  


    12. The directory ~/src in your virtual environment is linked to the src directory respectively in the cs128env folder on the host (i.e., your machine).  In other words, it is a shared folder between the virtual environment OS (operating system) and your computer’s OS.  
        a. Note: you should create subdirectories within the src folder for each assignment in this course and will be able to access that code on both your local machine and virtual environment.

    13. Let’s compile and run our first program in our virtual environment through the command line.  Verify you’re still logged into the virtual environment (vagrant@...).

    14. Then change into your src directory (cd ~/src) and execute the following sequence of commands:  
        a. clang++ -std=c++20 -g -O0 -Wall -Wextra -Werror -pedantic  hello_world.cc -o hello_world
        b. ./hello_world
    15. You should have seen “Hello, World!” printed to the screen, as shown in the screen capture above.

    16. You can continue to explore the virtual environment via the command line.  

    17. Once you’re done browsing, log out of the virtual environment by typing logout.

    18. After logging out, your virtual environment is still running in the background. To shut it down, type docker stop cs128env
Microsoft Visual Studio Code Set-up and Configuration + Launching the Development Environment 
We're now ready to set up and configure Microsoft Visual Studio Code!  Continue the process here: https://docs.google.com/document/d/1KEwzWGvmId9PKakH5QLz7jXvsayZJ5kw4ljkZg5_TRE/edit?usp=sharing 

Development process forward
Whenever you’re developing source code for this class, you should do so in the CS-128 development environment.
Start the Docker desktop application.  
You must always launch a terminal window, navigate to your cs128env directory, and execute docker start cs128env to start the virtual environment.  
You will subsequently launch Microsoft Visual Code and connect to the remote machine by navigating to View→Command Palette and then typing/selecting “Remote-SSH: Connect to Host”.
  
Subsequently, enter vagrant@127.0.0.1:2222 to connect VS Code to your virtual environment.  
Open the /home/vagrant/src folder.
Write your code VS Code and then compile it through the terminal window provided.  For now, you’ll write out the compilation command entirely.  Eventually, we will write Makefiles to simplify this process. 

Once you’re done developing, exit VS Code and shut down the virtual environment by executing the docker stop cs128env command inside the cs128env folder.
Exit the Docker desktop application 

More products