Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment page #33

Merged
merged 7 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pages/hack-school/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"git-github": "Git/GitHub",
"html": "Week 1: HTML",
"css": "Week 1: CSS",
"js": "Week 2: JavaScript"
"js": "Week 2: JavaScript",
"deployment": "Week 6: Deployment"
}
69 changes: 69 additions & 0 deletions pages/hack-school/deployment.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Week 6: Deployment

## What is deployment?

Deployment is the process of publishing your code on a server so that it becomes accessible over the internet. If you develop a project, your computer can act as a server, but all user interaction might be locally limited. Production-level applications are all deployed on servers, enabling multiple
users to access and interact with them.

## How do servers (briefly) work?

Recalling back to our discussion on clients and servers in week 4, clients send requests to servers for data, and servers process these requests and send back data in the form of a response.
Formally, a server is a specialized computer that can accept requests made by clients across a network.

nik-dange marked this conversation as resolved.
Show resolved Hide resolved
Servers are linked to a network via **IP addresses**. IP addresses are unique identifiers (similar to a home address), allowing distinction between servers. This IP address is where data packets are sent (from the client's requests). Learn more about
IP addresses here.
nik-dange marked this conversation as resolved.
Show resolved Hide resolved

From a client perspective, using IP addresses to access a server is impractical, since IP addresses are long alphanumeric sequences. This is where the **Domain Name System (DNS)** comes in.
Domain names (such as acmucsd.com or apple.com) are much more human readable, and are mapped to IP addresses through the DNS. When a user enters a domain name into their client, a DNS resolution request is sent to
a **DNS resolver** to find the corresponding IP address, to access the data in question (in our case, the user interface of apple.com).


## Deploying a front-end with Vercel

[Vercel](https://vercel.com) is a popular platform for deploying front-end interfaces and serverless applications–particularly those written with Next.js. A alternative option might be Netlify, but this guide will
demonstrate the use of Vercel.

You can create an account with Vercel (use your GitHub to link all your existing repositories). You should now have the option of importing a project.

Next, you can configure certain settings. For example, if you have both a `client` and `server` directory in your repository, you'll want to change the
Root Directory to point to the one with front-end code. You can also specify any build commands or environment variables at this stage.

![Vercel configurations](pages/hack-school/images/vercel_config.png)


If you want to change these settings later on, they can be found under the specific project settings page.

Finally, deploy your project! You should see this interface, where you can view active branches, the status, logs, and more.
khushijpatel marked this conversation as resolved.
Show resolved Hide resolved



## Deploying a back-end with Render

After deploying your front-end, you'll also need to deploy your API. You could run it on your personal computer, but once your app begins to scale, your computer's hardware
may not be adequate enough to handle the incoming load. When you use a service (we'll be using [Render](https://render.com)), you can generally specify the computing
capabilities of your server. More powerful configurations will scale up in price.

To get started with [Render](https://render.com), create a new [web service](https://dashboard.render.com/create?type=web). Link it to the correct GitHub repository and give it an appropriate name. You can adjust
configurations here, such as the branch you want to deploy from, runtime environment (e.g. Node, Python3), root directory (perhaps a `server` directory), and
build commands (like using `npm start` or `yarn dev` to start your server).

> Pro Tip: You can set up automatic deployments on pushes to the corresponding branch, removing the need to manually deploy every time you make a change!

![Render configuration](pages/hack-school/images/render_config.png)

Once this is specified, select an instance type. For small projects, the Free tier is more than enough. If you expect your app to scale, you may want to research
how much compute your app needs!

Finally, add environment variables and adjust any other configurations you need.


## What's next?

Congratulations––your application should now be accessible to users on the Internet! This is a great first step to building web applications.

In the future, you may want to consider scalability. Once your app starts gaining users and experiencing higher levels of stress, it might be time to include components such as
load balancers. If your application continues to grow to support more functionality, it might be worth considering splitting your architecture into microservices. Each of these approaches have their
own considerations, so make sure to do some research!



Binary file added pages/hack-school/images/render_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pages/hack-school/images/vercel_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading