Introduction to GitHub Codespaces
For a very long time in the software industry, applications were developed and hosted on the on-premises infrastructure. Applications were either used internally or made available on the internet. And with the advent of the cloud, the contribution of the on-premises infrastructure was reduced drastically. Since the software could be hosted on a cloud environment, there was a lower dependency on the software development team who no longer had to spend their precious time on setting up the infrastructure or handle other issues related to it.
There are different types of cloud which got expanded over time due to its innovative use cases. For example, with the help of Software as a Service (SaaS) offering from the cloud, desktop applications such as word processors were made available online, which made it easier to write documents on the fly. All that you need was internet access.
Remember, every software is using a programming language. Just like you use word processors to manage documentation activities, you can use an Integrated Development Environment (IDE) to develop software using a programming language.
Now the question is, as we move to the cloud era, wouldn’t it be an advantage to make the IDE available through a browser? This will obviously help in saving time installing the IDEs in your local. One such solution is Git codespaces, which is an online development environment. In this blog post, let us see what is GitHub Codespaces and also look into the practical implementation of it.
Table of contents
- What is GitHub Codespaces?
- How to use Codespaces?
- Configuring Codespace for repository
- Exploring Codespaces
- Conclusion
What is GitHub Codespaces?
Codespaces is a cloud-based online development environment. It allows developers to develop software in the cloud. It is all about the feature 'contribute from anywhere', which makes it easier for the developers to develop the application without any dependencies or the need to possess a high-end machine or even installing the IDEs in the local machine.
It comes with a text editor that can highlight the syntax and provide auto-complete suggestions. It also offers a terminal window, debugging tools, and Git commands. And the best part is, all of them are present within GitHub. Also, Visual studio codespaces(Developed by Microsoft) will be consolidated into GitHub Codespaces in the coming days.
How to use Codespaces?
Currently, GitHub has released only the beta version of the codespaces. Even though the beta version is available publicly, it is available only on a registration and availability basis. Users have to register for the beta version using this link. Based on the availability, GitHub will allocate the codespaces and notify the user.
During the beta version, users can create up to two codespaces for any public or private repositories. But, in the beta release, repositories of organization or repositories that require SAML SSO are not supported. The codespace that is created by you is not sharable. In the scenario where the user wants to use the third codespace, the user has to delete any one of the existing Codespace to accommodate the latest one.
It provides the option to connect the codespace from the visual studio code. Also, for the repository, a default codespace configuration can be created, which allows setting framework, tools, extensions, and ports required for working on the repository.
Configuring codespace for repository
As we discussed in the previous section, GitHub allows users to create a default codespace configuration for a repository. By this, developers who develop software for the particular repository will have a similar setting so that all the dependencies that are required to run the solution are handled at one point.
You might have a question now. Is it mandatory to define a configuration for the repository? And what happens to my codespace if I don't define it?
Github by default creates Linux image-based codespace which includes tools for C++, Java, C#, .Net core, JavaScript, Typescript, Python, PHP, and Powershell.
Codespaces makes use of the configuration present in the devcontainer.json file to provide the default setting. The JSON file is located either in the folder .devcontainer in the root directory or the file can be placed in the root directory with the name .devcontainer.json.
Codespaces are free to use during the beta period. Once publically available, users will be charged for the storage and computation power that is being utilized.
Costs are incurred based on the active time of the codespace. Active time is the time when the users use the codespace. After 30 minutes of inactivity, the codespace will be suspended.
Exploring Codespaces
To get hands-on in GitHub Codespaces, users have to register for the beta version as mentioned earlier. Once the users get the notification to access the GitHub Codespaces, users can try the below steps to access the codespace.
Step 1
Create a new repository in GitHub or use the existing repository of your choice that is present in GitHub
Step 2
Navigate to the repository and look for a green color button at the top right corner with a label of 'Code'. Click on it.
Step 3
Selectr the option 'Open with Codespaces' in the dropdown.
Step 4
On clicking 'Open with Codespaces', GitHub provides the option to open an already created or new codespace.
Step 5
On clicking this, a screen similar to that of the options in visual studio code appears with a small left pane to show the opened files along with tracking changes. The remaining area is the code editor.
After completing the changes, users can track the changes and push the changes to the respective branch from the codespace.
Conclusion
Working on the go without having dependencies on the machine is possible with the advent of cloud-based solutions. Running the GitHub Codespaces is simple, easy and it takes only seconds to get loaded. Codespaces also provide pre-built libraries that can be used based on their needs.