Containerize your development environment.

High chance you guessed it right, we will be using Docker.

Docker is a great, famous, and very tool. But remember if you use it wrong you end up breaking the traffic of your CI/CD, so don't forget to practice and to use proper versioning organization.



Before you continue, this article is covering only the use of VSCode, If you want to know how you can use other Editors to achieve your goal, you have to do some more digging (if you found something interesting, I'd love if you share it with me 😉 )

Why I would do this?

I know you're here because you already had reasons to think it's a good idea to sync the development environment between the team members.

Maybe you want to add my situation to your reasons, I work with flutter, recently they released Flutter 2 which has breaking changes if you want to upgrade.

If you have a small project that depends on one or two packages or maybe no packages at all like my pet project Dart Stack you might need to upgrade your project (sometimes your users will ask you to do that if it's a package).

If you have a big project like the super-secret very important amazing app I'm working on with a team of the top flutter developers, you will have way many packages to depend on that need to be upgraded first and that would take time, an unknown number of days or weeks.

Well, having two laptops is a solution, a silly one though?

Maybe you will upgrade and downgrade your SDK every time you switch between projects, if you think you can do that you might as well develop a 3D game using assembly language and vim, nobody wants to do that.

But, If you can use Docker to have isolated different machines to use for different projects, that would be amazing.

Let's get to work

First of all, you need to have Remote Tools extension installed in your VSCode, Maybe you would love to have Docker extension as well.

Now create the file .devcontainer/devcontainer.json and add this inside:


{
  "name": "Put a name here",
  "image": "put image name here",
  "extensions": [extensions you need them installed in vscode in the container]
}

for example, my flutter file would look like this:

{
  "name": "Flutter",
  "image": "cirrusci/flutter:stable",
  "extensions": ["dart-code.dart-code", "dart-code.flutter"]
}

You can find a reference to the file Here.

Now all you need to do is to open the command palette (Cmd+Shift+P in MAC) and write "Reopen in container".

That's it, You're all set, very simple right?

Yeah, you should figure out other complicated stuff like preparing the docker image that has all things you need, maintaining that image as well, but just imagine how much work that would save for you? probably a lot.

Comments

  1. This comment has been removed by a blog administrator.

    ReplyDelete

Post a Comment

Popular posts from this blog

Teaching programming to children can be evil

Composition VS Inheritance in stack's implementation