VScode: How to Chain Multiple Devcontainer for Development

Weseek-Inc - Jun 4 - - Dev Community

Introduction

Hello, I am Ise, an engineer at WESEEK who is in charge of the development and operation of GROWI.cloud.

In this issue, I would like to share a story about a time when I encountered a troubling problem in the development of GROWI.cloud and solved it.


Background

  • GROWI.cloud develops mainly in node.js, and its projects are divided into “Project A”, “Project B” and so on, according to their roles.
  • GROWI.cloud's services are made possible by these “Project A” and “Project B” communicating with each other.
  • Recently, we have decided to use VSCode's devcontainer(, docker-compose) for our development environment.
  • The devcontainer change had no impact on the development of individual projects, as they were all linked with other projects using the internal test environment.
  • However, when “Project A” and “Project B” were developed, the devcontainers of both projects could not communicate with each other and hindered the development.
  • Therefore, I reviewed the settings around the network of devcontainer, and decided to improve the development environment to enable communication between multiple devcontainers.

What I did

  • Add a setting that allows the network to be specified when the docker-compose of devcontainer is started

Thus, when devcontainer is built, if there is no Docker network, it will be created automatically.

Setting

*By adding the same configuration to Project B, it is possible to connect to the same namespace network regardless of whether devcontainer of Project A or B is started first.

On the same Docker network, you can resolve names by service name

  • Fix service names in devcontainer/docker-compose.yml so that they are not covered by Projects A and B

*Service names in the same Docker network cannot be resolved correctly if they are the same, so even if they are different projects, it is necessary to make sure that the service names do not overlap.

Fix service names

Now you can name resolve node.js apps in Project A as node, node.js apps in Project B as node-project-b, and so on!

  • Set network in .devcontainer/docker-compose.yml to connect to the same network

Set network1

Set network2

  • Review correspondence destination

*Before devcontainerization, the communication destination was sorted by “port number” of localhost, but now it is possible to communicate by specifying the service name, so it has been modified.

example: When sending a POST request from Project A to Project B

Review

  • Rebuild container

Rebuild Container

That's all I did!
Hope everyone has a good devcontainer LIFE!


About Us💡

In addition, we want to introduce a little more about GROWI, an open software developed by WESEEK, Inc.

GROWI is a wiki service with features-rich support for efficient information storage within the company. It also boasts high security and various authentication methods are available to simplify authentication management, including LDAP/OAuth/SAML.

GROWI originated in Japan and GROWI OSS is FREE for anyone to download and use in English.

For more information, go to GROWI.org to learn more about us. You can also follow our Facebook to see updates about our service.

GROWI.org

. . . . . . . . . . . . . . .