-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #522 from MikaelStr/master
#Devcontainers post
- Loading branch information
Showing
3 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
--- | ||
layout: post | ||
title: Devcontainers - Goodbye to dependency hassle | ||
author: mikaelstr | ||
excerpt: Describes devcontainers and how to use them to setup development environments easily. | ||
tags: | ||
- Devcontainers | ||
- Development | ||
--- | ||
|
||
|
||
 | ||
|
||
## Devcontainers: Goodbye to dependency hassle | ||
|
||
Every time a developer starts on a project they need to go through the process of setting up a development environment. This can be a smooth half day work, or an installation / googling frenzy for a week, especially for legacy code. | ||
|
||
This is where devcontainers could be a helper. | ||
|
||
Devcontainers, or development containers, are a type of containers used specifically for development purposes. They allow you to use containers as a full-featured development environments, providing a way to separate tools, libraries, or runtimes needed for working with a codebase. | ||
|
||
## How do they work | ||
|
||
Devcontainers are using a devcontainer.json file and a Dockerfile to define the container's configuration. This allows you to customize your dev container with additional tools, extensions, ports, and features. | ||
|
||
Benefits of using devcontainers | ||
|
||
Consistent environment: Devcontainers provide a consistent development environment for everyone working on a project, reducing the "it works on my machine" problem. | ||
Isolation: Devcontainers allow you to isolate your development environment from your local machine, reducing the risk of conflicts between different projects. | ||
Easy setup: Devcontainers make it easy to set up a development environment, especially for complex projects with many dependencies. | ||
|
||
## When to use devcontainers | ||
|
||
Devcontainers are particularly useful when working on projects with complex dependencies or when multiple developers are working on the same project. They can also be helpful when working with different versions of tools or libraries, or when you need to switch between different projects frequently. | ||
|
||
## When not to use devcontainers | ||
|
||
Devcontainers may not be necessary for simple projects with few dependencies. They can also add some overhead, so they may not be the best choice for projects where performance is critical. It needs to have a container environment installed (Ex. Docker). | ||
|
||
## IDE examples | ||
|
||
Devcontainers supports a lot of different IDEs and extensions. Here are some examples: | ||
|
||
- Visual Studio Code | ||
- Github Codespaces | ||
- IntelliJ IDEA | ||
|
||
|
||
## Test example | ||
|
||
- **IDE:** Visual Studio code dev container extension. | ||
- **Code:** ASP.NET Core Web API Backend. | ||
- **Tested on:** Both on Mac and Windows. | ||
|
||
|
||
How to test: Get [code](https://github.com/MikaelStr/DevContainerRESTBackend) from git, launch VSCode (Ext. Devcontainer) . Ready! | ||
|
||
Devcontainer file uses a "ms-dotnettools.csharp" extension which is a C# extension provided by Microsoft. This extension provides features like IntelliSense, code navigation, and debugging support for C# code. | ||
``` | ||
{ | ||
"name": "ASP.NET Core", | ||
"dockerFile": "Dockerfile", | ||
"forwardPorts": [5000, 5001], | ||
"settings": { | ||
"terminal.integrated.shell.linux": "/bin/bash" | ||
}, | ||
"extensions": ["ms-dotnettools.csharp"] | ||
} | ||
``` | ||
|
||
## Thoughts | ||
|
||
The devcontainer could be verified in a step in the CI / CD. This way keeping it validated automatically and even used to drive the build process. | ||
|
||
## Last words | ||
|
||
I hope this article will help you tackle some of the challenges that come with setting up new development environments. | ||
|
||
[Here](https://devblogs.microsoft.com/ise/dev-containers/) is a good post to start from if you want to learn more. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.