-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Pre-build images for Microsoft maintained container images in this repository #140
Comments
Currently the vscode-dev-containers repo contains pure Dockerfiles that need to be built when used. While this works well from the perspective of providing samples, some of the images install a significant number of runtimes or tools which can take a long time to build. The goal of this proposal is to:
We won't be able to build all images in the repository or publish them under a Microsoft registry, but we would want to allow contributors to build their own images for contributions if they wanted to do so by keeping the ability to use a stand alone Dockerfile, image reference, or docker-compose file like today. Image generation for vscode-dev-containersIn order to meet the above requirements, this first phase keeps the way the dev containers deployed as it is now - an npm package. Future phases could introduce a formal registry, but this is overkill current state. VersioningAt this phase, versioning of the image can be tied to the release of the npm package. For example, as of this writing, the current version is 0.35.0. All images that are generated would then inherit this version. We would follow semver rules for bumping up the repository name - any fix that needs to be deployed immediately would be "fix" level semver bump. When released as latest, the image would be tagged as is done in other Docker images. Using the 0.35.0 example, new images would be tagged as:
In the unlikely event a break fix needed to be deployed and not tagged latest, we would have a facility to tag as follows:
This has a few advantages:
This scheme will work in the near term where we do not have a large number of dev containers in the repository, but over time will not scale. However, to realistically support independent versioning, we'd need to build out a registry service - which may or may not be required. This will be evaluated at a later date. Deprecation of container definitionsThe versioning scheme above allows us to version dev containers and reference them even when they are removed from
Since the images would continue to exist after this point and the source code is available under the version label, we can safely remove the containers from master without impacting customers. Release process and the contents of the npm packageWhen a release is cut, there are a few things that need to happen. One is obviously releasing the appropriate image. However, to continue to help customers understand how to customize their images, we would want to reference a user modifiable "stub" Dockerfile instead of an image directly. This also is important to help deal with shortcomings and workarounds that require something like specifying a build argument. For example: FROM mcr.microsoft.com/devcontainer/javascript-node:0.35-10
ARG USER_UID=1000
ARG USER_GID=$USER_UID
ENV DEBIAN_FRONTEND=noninteractive
# [Optional] Update UID/GID if needed and install additional software
RUN if [ "$USER_GID" != "1000" ] || [ "$USER_UID" != "1000" ]; then \
if [ "$USER_GID" != "1000" ]; then sudo groupmod 1000 --gid $USER_GID; fi \
&& if [ "$USER_UID" != "1000" ]; then sudo usermod --uid $USER_UID 1000; fi; \
fi \
#
# ***************************************************************
# * Add steps for installing any other needed dependencies here *
# ***************************************************************
#
# Clean up
&& sudo apt-get autoremove -y \
&& sudo apt-get clean -y \
&& sudo rm -rf /var/lib/apt/lists/*
# Uncomment to default to non-root user
# USER $USER_UID
# Switch back to dialog for any ad-hoc use of apt-get
ENV DEBIAN_FRONTEND=dialog This retains its value as a sample but minimizes the number of actual build steps. This template would evolve over time as new features are added. For example, the above Dockerfile includes a way to make sure the user's GID/UID matches the local operating system - which is critical for Linux users. However, if we introduce a Referencing The MAJOR.MINOR version in this Dockerfile allows us to push fixes or upstream updates that do not materially change the definition. Repository contentsConsequently, this user stub Dockerfile needs to be versioned with the
Here, Testing, then, is as simple as it is now - open the folder in In the vscode-dev-containers repo itself, the FROM mcr.microsoft.com/vs/devcontainer/javascript-node:dev-10 Release processWhen a release is cut, the contents of vscode-dev-containers repo would staged. The build process would then do the following for the appropriate dev containers:
These modified contents are then archived in an npm package exactly as they are today and shipped with the extension (and over time we could dynamically update this between extension releases).
|
TLDR; I am effectively ready to start merging this in, but given I'm about to be out for Thanksgiving, I'm going to hold off. We'll need to swap out CI processes for this repository when we are ready and merge a PR I'll create for the remote containers extension itself. I suspect this is going to be like the image testing where we'll clog up ADO agents, so I used GitHub Actions to wire this up. The only thing we'll want ADO to do is to do the automatic CG processing. Here's where I am with getting this working.
The build CLI (
Image build/push is managed using config in For example, currently this builds 7 images:
This results in just three "repositories" in the registry much like you would see for other images in Docker Hub.
The package version is then automatically added to these various tags as a part of the release. For example, release 0.40.0 would result in: mcr.microsoft.com/vscode/devcontainers/base
In this case, Debian is also the one that is used for There's a special "dev" version that can be used to build master on CI - I ended up needing this to test and others would if they base an image off of one of the MCR images. e.g. Another problem this solves is common changes - there's a set of things we want in every image and right now it requires ~54 changes to add things. With this new process, images use a tagged version of scripts in The process also automatically swaps out referenced MCR images for MAJOR.MINOR versions of built images in any Dockerfile that is added to the package. This allows us to push break fix and or security patches as break fix releases and people will get them. The build supports an option to not update Net-net, we should be able to add and manage images easily while still allowing us to take simple Dockerfile contributions. |
Very cool! |
I've now onboarded the first set of images into MCR and we have a syndication page in DockerHub. Now that 1.41 is out, the last step is merge into master and transition the CI build steps from ADO to these GitHub actions. I'll also document how to get things working. |
Resolved with #189. |
Currently this repository includes a number of dev containers for people to use, but requires that the images be built. While this is great for an example, certain definitions like debian-9-git could clearly have a base image with git already installed and then just a sample Dockerfile for using it.
We can cherry pick a subset of these that are maintained by Microsoft and pre-build them much as we recommend for external contributions.
The text was updated successfully, but these errors were encountered: