IT490 Midterm
What is the advantage of using a .env file and referencing it from docker-compose.yml?
A .env file allows you to have a single source of information for things that may be used by multiple services. This way you only have to make a change in one file if you want to make an adjustment. This helps prevent errors due to forgetting to change a variable in multiple places. It also allows you to store your secrets in one file that you can then keep out of your public repository.
What are the two components of a YAML mapping? Give an example to illustrate your point.
A key (or a keyword) and a value. key: value
Why would a project choose to use a messaging framework?
A messaging framework allows you to build components and not have to worry about the minutiae of how they will interface with other components. Messaging libraries are available for most languages and are easy to integrate. Using a messaging framework also allows you to perform auditing to better analyze your application.
What is a remote and what does the git push command do?
A remote is a non-local server (typically external) that stores your git repository. The git push command pushes the current version of your git repository to the remote server. It is usually used after you have completed a commit so that the other members in your team have access to the new version of the repository.
What is AMQP?
AMQP is a standard and open messaging protocol used by many messaging frameworks and client libraries.
What does the adminer image do?
Adminer provides a web-based interface to your database. This can be very useful for looking at the data in your database and making sure everything is working the way you expect it to.
Why is port 5000 the only port that needs to be forwarded to the local host?
All other communication in this system takes place inside the Docker network that Docker Compose builds. The only interface a user needs to this system is through port 5000 on Front End.
What is an exchange format and why is it important?
An exchange format details how messages are represented. For example, if a project was using JSON as an exchange format you could expect all of the messages to be parseable using a JSON parser.
How do Back End and Front End communicate?
Back End and Front End communicate via the Messaging framework.
What three things does Back End have to do?
Back End has to communicate with the database, communicate with messaging, and perform any extra tasks required such as web scraping.
What is backend responsible for?
Back End is responsible for reading messages from Front End, storing things in Database, and acquiring any other data needed. It has no user-facing component, which spares us the trouble of having to run another web server. Everything can basically be done with a single script.
How does YAML signify different blocks?
Blocks are signified through indentation in YAML. This is similar to how Python delineates blocks.
What is caching and what are its benefits?
Caching stores a known result for a particular input. This allows you to quickly return a result without having to do the back end work that may typically be required. It can provide greater responsiveness for common client message flows.
What does Docker Compose do and how it is different from the docker command?
Docker Compose allows you to use a YAML to start up multiple containers with various options. This lets you build a multi-container system easily. The docker command is used to build/run individual containers.
How are environment variables used in Docker Compose and what kinds of things can they be used for?
Docker Compose uses environment variables to pass information to containers that are being started. This information could be URIs to connect to, usernames, passwords, or any other information that is needed at run time.
Explain Docker run
Docker can run containers by taking images, copying the file system, and running commands on that file system within an isolated environment. This is called running a container. You can run several containers from the same image since the file system is cloned.
Why might a team want to use pull requests instead of adding all contributors as collaborators to a project?
Even though all changes in a git repository can be rolled back if needed, it can be time consuming and annoying for a large project to have to keep reverting changes. By having contributors submit PRs, an integration team can review the changes and only commit code that meets their standards.
What are issues in GitHub?
Issues allow you to keep track of bugs that need to be fixed, milestones that need to be completed, or other general TODO items. It also gives you a place to have a dialog about the project you are working on.
What is the purpose of messaging?
Messaging allows multiple components to use a common medium to exchange information. The goal is to create a system that is more extensible, resilient, and scalable. By using a messaging framework you can establish the interfaces between components and worry less about idiosyncrasies of communication.
What role does Messaging play in this system?
Messaging brokers the communication between Front End and Back End. By using a Messaging layer, we make our system more scalable. In the future we may wish to run multiple Front Ends or Back Ends. With a Messaging layer that transition should be simple.
What is the difference between persistent and ephemeral data?
Persistent data is data that is stored for a long time, it survices container restarts. Ephemeral data is data that only lasts for the life of the container.
git push
Publishes committed local files to remote repo.
What does RPC stand for and what is it?
RPC stands for Remote Procedure Call and it is a technique where the client specifies what function they want to execute and which parameters they wish to pass. Upon successful completion they server gives the client the result of running that function.
How would you comment out a line in a YAML file?
The # character at the beginning of a line comments out the whole line.
How do you create a new repository in a directory?
The git init command turn the working directory into a git repository. Note that you need to be in the directory that you want to make into a repository.
What is the purpose of a front-end?
The purpose of a front end is to interact with the user
A new member joins your team. As the maintainer of the repository on GitHub, what steps do you need to take so that they have commit access to the repository? What steps does the group member need to take to get set up?
The team member will need to set up a GitHub account and tell you what their user name is. Once they have done that, you will need to add them as a collaborator to the repository that you want to share with them.
What does it mean that files are staged for a commit?
These are files that have been marked to be included in the next commit. Typically they have changes in them and they are part of a larger change to the entire project. They aren't committed yet, but once you perform the commit action and enter a commit message they will be.
What are the advantages of this socket front end, as opposed to the front end demonstrated in Front End?
This front end will not have to keep reconnecting to messaging. This should improve the responsivity of the web application.
What does the expandtab or "replace by spaces" option do in a text editor and why is it important to use when working with YAML?
This option inserts a series of spaces every time the tab key is pressed. This is important because YAML uses indentation to define blocks and the characters used to indent need to be consistent. With this option you can use the tab key and not have to worry about whether you are inserting a tab or a space.
What is the purpose of Docker?
Traditionally, virtualization has made use of a virtual machine (VM) to provide an isolated environment in which an operating system (OS) and applications can run. This allows the application to have a completely custom environment and ultimately makes it easier to deploy.
git add
Used when you need to tell git which files you want it to track and when you want to stage them to be committed. The first time you use this command it begins tracking the file and stages it for a commit. The second time you use git add only stages that file for a commit.
What are the advantages of using version control?
Version control allows you to keep track of all changes to a set of files. If something goes wrong and you need to get to a previous state, you can. Likewise, if you want to see how you did something in the past you can look through a history of changes. Finally, version control makes it easier for teams to work together by helping resolve conflicts when two authors change the same file.
What is version control?
Version control tracks changes to a group of files. If you are working with a version control system, you could easily see what you changed and even roll-back your changes.
What is the purpose of web sockets?
WebSockets allow full duplex communication between a client and server over a single HTTP connection. By using WebSockets, we can build an efficient SPA that connects to Messaging in the same way as our other Front End examples.
Are nested structures possible in YAML? Give an example.
Yes.
What are the most important criteria when picking a language to develop a front end in?
You need to pick a language that your Front End teammate is comfortable with.
How can you specify that you want to enable the management interface in the official RabbitMQ Docker image?
You need to use the management image as specified in the version name: rabbitmq:3.8 vs rabbitmq:3.8-management
What is the purpose of Github?
a service that provides a space for remote git repositories. It features an extensive web interface and several project management features.
git clone
creates a local copy of a remote repository.
How would you run a shell on an already running container?
docker run -it <container-id> bash
What are the two things that the git add command can do?
git add can tell git to begin tracking a file and it can tell git to stage a file for the next commit.
What is the common package manager for Node.js?
npm: Node package manager
git commit
permanently stores file changes from the staging area in the repository
git remote add origin <url>
sets up a remote origin
What is the difference between a Docker image and a Docker container?
A Docker image is a filesystem snapshot, but a Docker container is an actual up and running instance of a container. When you run the docker ps command it will show you what containers are running. When you run the docker images command it will show you what images and available.
What is a Dockerfile?
A Dockerfile is a list of basic instructions for building an image. Instructions are typically capitalized. FROM and COPY. FROM tells Docker that you want to build an image on top of another image. We also use the COPY instruction to copy a local file into the image we are building.
What is the difference between a VM and a container?
A VM emulates an entire machine including the operating system kernel while a container runs within the current operating system kernel. This makes containers less resource intensive than VMs.
What is a WebSocket and what does it allow you to do?
A WebSocket is a full duplex connection between the client and the server. This allows you to design applications that easily receive real-time updates from the server.
Why are we using a messaging layer for communications with Front End?
A messaging layer allows us to scale our application by running multiple Front Ends and not have to worry about the specifics of how they will communicate with Back End.
Why should you change the RabbitMQ default password and how do you change it?
Even though your internal Docker network will not be exposed to the outside world, it is still a good practice to set a RabbitMQ password that is different from the default. This can be done by changing the RABBITMQ_DEFAULT_PASS environment variable on the Messaging container.
Containers vs. VMs
Every VM having to run its own OS and emulate a unique machine creates a lot of overhead. Containers allow for similar isolation as VMs, but at a reduced resource cost since ass opposed to VMs which emulate a physical machine, containers use control groups, namespaces, and chroot to allow containers to share the same operating system, but still be isolated. A server running containers has significantly less overhead
Describe the most common package management option for one of the following environments: Python, PHP, or JavaScript.
For Python, PIP is the most commonly used for installing packages. PIP allows you to install packages including their dependencies making it easy to setup your environment on another system. These packages are typically listed in a requirements.txt file in the root of your Front End tree. For node (server-side Javascript), that's the Node Package Manager (NPM). NPM utilizes a package.json file that tells it what dependencies to install and how to run the application:
What does GitHub provide for a project?
GitHub provides a remote repository and several project management tools including an issue tracker. Both the repository and the tools have built-in web interfaces.
Why do we store password hashes instead of just the passwords?
Hashes are more secure because they are a one-way function. You can convert a password to its hash, but you cannot convert a hash to its password. As such, if your system is compromised an attacker would not get the passwords of your users.
What is ephemeral vs persistant storage?
In a container environment, it is very important to make the distinction between ephemeral and persistent storage. A container may have lots of information on its filesystem but if that container is stopped, that information is lost. All persistent information, that is information that needs to survive the container lifecycle, should be stored on a database which utilizes an external volume. Having persistent storage needs makes a container stateful.
What is YAML?
In the long-standing tradition of informal, recursive acronyms, YAML stands for YAML Ain't Markup Language. It is designed to be a plain text way to represent complex objects. It is easier to read than JavaScript Object Notation (JSON), but not as complex as Extensible Markup Language (XML). YAML uses indentation to specify scope, like Python, and therefore spacing matters.
git init
Initializes a new Git repository. Creates a .git subdirectory in the project root, which contains all of the necessary metadata for the repo. Aside from the .git directory, an existing project remains unaltered.
What does the -d option do when passed to the docker run command? When may you want to use it? When may you not want to use it?
It runs the container in the background. You may want to use it if you have a long running container answering requests, such as a database container. You may not want to use it if you are debugging something and you want to quickly see the container output as the container is running.
What is the difference between using git and GitHub?
git is the version control system and GitHub is a website that provides additional project management tools and a web interface for a git repository. git can be used independently of GitHub.
git pull
update local repository with what is in remote repository