Unify Development Environment via VSCode remote-containers
Prologue
I was a heavy user of Vagrant and Puppet with a long time, but maintain them to make sure the development environment can be deployed as usual sometimes make me feel annoy, especially cross multiple Linux distribution or versions. All of my existing projects have been migrated to container solution in recent years, then “Utilize the well packed docker image as development environment must be a good idea.”
Concepts
VSCode remote-containers provide an excellent and isolate development environment for developers, and it would be possible to utilize the benefit and merge with our application image that we are running on production.
Thanks for the container design, we could simply stack the remote-container layer to an existing docker image like following diagram:
Based on above concept, we should refer to the base Dockerfile and snipping some of them to my existing Dockerfile. Following section shows a sample project which is already adapt this concept and works on VSCode.
Instructions
Step 1. Install Docker and VSCode with the extension: remote-containers
Step 2. Clone the sample project : cjy0125/godevcontainer (github.com) and execute following commands
# Clone repo
git clone git@github.com:cjy0125/godevcontainer.git
cd godevcontainer
# Prepare resources for remote container
bash ./setup_script.sh alpine
Step 3. Open remote container in VSCode
Click the button at bottom left corner, and choose “Remote-Containers: Open Folder in Container”, then select the folder that we cloned in previous step.
Step 4. Wait the development container build success
Once the development environment is ready, then we could save this in project manager.
Epilogue
Unify development environment is always a key point to put all the cooperators on the same page. In addition it could mitigate the gap and assist the new comer to start contribution ASAP.
References
Developing inside a Container using Visual Studio Code Remote Development