Skip to content

Commit

Permalink
dev container CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmarti committed Apr 27, 2022
0 parents commit b5178df
Show file tree
Hide file tree
Showing 86 changed files with 13,711 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
ARG VARIANT="16-bullseye"
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT}
25 changes: 25 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
{
"name": "Dev Containers CLI",
"build": {
"dockerfile": "Dockerfile",
"args": {
"VARIANT": "16-bullseye"
}
},

"extensions": [
"dbaeumer.vscode-eslint"
],

"postCreateCommand": "yarn install",

"remoteUser": "node",

"features": {
"docker-in-docker": "latest"
}
}
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/node_modules/**
63 changes: 63 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
module.exports = {
'env': {
'browser': true,
'node': true
},
'parser': '@typescript-eslint/parser',
'parserOptions': {
'sourceType': 'module'
},
'plugins': [
'@typescript-eslint'
],
'rules': {
// '@typescript-eslint/class-name-casing': 'warn', https://github.com/typescript-eslint/typescript-eslint/issues/2077
'@typescript-eslint/member-delimiter-style': [
'warn',
{
'multiline': {
'delimiter': 'semi',
'requireLast': true
},
'singleline': {
'delimiter': 'semi',
'requireLast': false
}
}
],
'@typescript-eslint/semi': [
'warn',
'always'
],
'constructor-super': 'warn',
'curly': 'warn',
'eqeqeq': [
'warn',
'always'
],
'no-async-promise-executor': 'warn',
'no-buffer-constructor': 'warn',
'no-caller': 'warn',
'no-debugger': 'warn',
'no-duplicate-case': 'warn',
'no-duplicate-imports': 'warn',
'no-eval': 'warn',
'no-extra-semi': 'warn',
'no-new-wrappers': 'warn',
'no-redeclare': 'off',
'no-sparse-arrays': 'warn',
'no-throw-literal': 'warn',
'no-unsafe-finally': 'warn',
'no-unused-labels': 'warn',
'@typescript-eslint/no-redeclare': 'warn',
'code-no-unexternalized-strings': 'warn',
'no-throw-literal': 'warn',
'no-var': 'warn',
'code-no-unused-expressions': [
'warn',
{
'allowTernary': true
}
],
}
};
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto
*.bat eol=crlf
*.cmd eol=crlf
*.ps1 eol=lf
*.sh eol=lf
34 changes: 34 additions & 0 deletions .github/workflows/build-chat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build Chat

on:
workflow_run:
workflows:
- '**'
types:
- completed
branches:
- '**'

jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Checkout Actions
uses: actions/checkout@v2
with:
repository: "microsoft/vscode-github-triage-actions"
path: ./actions
- name: Install Actions
run: npm install --production --prefix ./actions
- name: Install Additional Dependencies
# Pulls in a bunch of other packages that arent needed for the rest of the actions
run: npm install @azure/storage-blob@12.1.1
- name: Build Chat
uses: ./actions/build-chat
with:
token: ${{ secrets.GITHUB_TOKEN }}
slack_token: ${{ secrets.SLACK_TOKEN }}
storage_connection_string: ${{ secrets.BUILD_CHAT_STORAGE_CONNECTION_STRING }}
workflow_run_url: ${{ github.event.workflow_run.url }}
notify_authors: true
log_channel: bot-log
52 changes: 52 additions & 0 deletions .github/workflows/dev-containers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Dev Containers CI

on:
push:
branches:
- '**'
pull_request:
branches:
- '**'

jobs:
cli:
name: CLI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '16.x'
registry-url: 'https://npm.pkg.github.com'
scope: '@microsoft'
- run: yarn
- run: yarn package
- run: yarn test --forbid-only
- name: TGZ name
run: |
VERSION=$(jq -r '.version' < package.json)
echo "TGZ=dev-containers-cli-${VERSION}.tgz" | tee -a $GITHUB_ENV
echo "TGZ_UPLOAD=dev-containers-cli-${VERSION}-${GITHUB_SHA:0:8}.tgz" | tee -a $GITHUB_ENV
- name: Store TGZ
uses: actions/upload-artifact@v2
with:
name: ${{ env.TGZ_UPLOAD }}
path: ${{ env.TGZ }}
container-features:
name: Test container-features
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: '16.x'
registry-url: 'https://npm.pkg.github.com'
scope: '@microsoft'
- name: Install Dependencies
run: yarn
- name: Compile
run: yarn compile
- name: Run Offline Tests
run: yarn test-container-features-offline --forbid-only
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
dist
node_modules
logs
*.log
*.tgz
tmp
.DS_Store
16 changes: 16 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
*.tgz
*.log
test
tsconfig*.json
src
tsfmt.json
scripts/gitAskPass.sh
*.js.map
build
azure-pipelines.yml
.vscode
.github
.gitattributes
.eslintrc.js
.eslintignore
.devcontainer
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
]
}
21 changes: 21 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"git.ignoreLimitWarning": true,
"search.exclude": {
"dist": true
},
"typescript.tsc.autoDetect": "off",
"eslint.options": {
"rulePaths": [
"./build/eslint"
]
},
"mochaExplorer.files": "test/**/*.test.ts",
"mochaExplorer.require": "ts-node/register",
"mochaExplorer.env": {
"TS_NODE_PROJECT": "src/test/tsconfig.json"
},
"files.associations": {
"devcontainer-features.json": "jsonc"
},
"typescript.tsdk": "node_modules/typescript/lib"
}
47 changes: 47 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"windows": {
"options": {
"shell": {
// Run Tests requires powershell on Windows.
"executable": "powershell.exe"
}
}
},
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"label": "Build Dev Containers CLI",
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
},
},
{
"type": "npm",
"script": "lint",
"problemMatcher": [
"$eslint-stylish"
],
"label": "npm: lint",
},
{
"type": "npm",
"script": "test",
"problemMatcher": [],
"label": "Run Tests",
"group": {
"kind": "test",
"isDefault": true
}
}
]
}
34 changes: 34 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Contributing

We're excited for your contributions to the development container CLI! This document outlines how you can get involved.

## Contribution approaches

- Propose the change via an issue in the [specification repository](https://github.com/microsoft/dev-container-spec/issues). Try to get early feedback before spending too much effort formalizing it.
- More formally document the proposed change in terms of properties and their semantics. Look to format your proposal like our [devcontainer.json reference](https://aka.ms/devcontainer.json), which is a JSON with Comments (jsonc) format.

Here is a sample:

| Property | Type | Description |
|----------|------|-------------|
| `image` | string | **Required** when [using an image](/docs/remote/create-dev-container.md#using-an-image-or-dockerfile). The name of an image in a container registry ([DockerHub](https://hub.docker.com), [GitHub Container Registry](https://docs.github.com/packages/guides/about-github-container-registry), [Azure Container Registry](https://azure.microsoft.com/services/container-registry/)) that VS Code and other `devcontainer.json` supporting services / tools should use to create the dev container. |

- You may open a PR, i.e code or shell scripts demonstrating approaches for implementation.
- Once there is discussion on your proposal, please also open and link a PR to update the [devcontainer.json reference doc](https://aka.ms/devcontainer.json). When your proposal is merged, the docs will be kept up-to-date with the latest spec.

## Review process

The specification repo uses the following [labels](https://github.com/microsoft/dev-container-spec/labels):

- `proposal`: Issues under discussion, still collecting feedback.
- `finalization`: Proposals we intend to make part of the spec.

[Milestones](https://github.com/microsoft/dev-container-spec/milestones) use a "month year" pattern (i.e. January 2022). If a finalized proposal is added to a milestone, it is intended to be merged during that milestone.

## Miscellaneous

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

This project is under an [MIT license](LICENSE.txt).
22 changes: 22 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) Microsoft Corporation.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Dev Container CLI

This repository holds the dev container CLI, which can take a devcontainer.json and create and configure a dev container from it.

## Context

A development container allows you to use a container as a full-featured development environment. It can be used to run an application, to separate tools, libraries, or runtimes needed for working with a codebase, and to aid in continuous integration and testing. Dev containers can be run locally or remotely, in a private or public cloud.

![Diagram of inner and outerloop development with dev containers](/images/dev-container-stages.png)

This CLI is in active development. Current status:

- [x] `dev-containers-cli build` - Enables building/pre-building images
- [x] `dev-containers-cli up` - Spins up containers with `devcontainer.json` settings applied
- [x] `dev-containers-cli run-user-commands` - Runs lifecycle commands like `postCreateCommand`
- [x] `dev-containers-cli read-configuration` - Outputs current configuration for workspace
- [x] `dev-containers-cli exec` - Executes a command in a container with `userEnvProbe`, `remoteUser`, `remoteEnv`, and other properties applied
- [ ] `dev-containers-cli stop` - Stops containers
- [ ] `dev-containers-cli down` - Stops and deletes containers

## Specification

The dev container CLI is part of the [Development Containers Specification](https://github.com/microsoft/dev-container-spec). This spec seeks to find ways to enrich existing formats with common development specific settings, tools, and configuration while still providing a simplified, un-orchestrated single container option – so that they can be used as coding environments or for continuous integration and testing.

Learn more on the [dev container spec website](https://devcontainers.github.io/containers.dev/).

## Additional resources

You may review other resources part of the specification in the [`devcontainers` GitHub organization](https://github.com/devcontainers).

## Contributing

Check out how to contribute to the CLI in [CONTRIBUTING.md](contributing.md).

## License

This project is under an [MIT license](LICENSE.txt).
Loading

0 comments on commit b5178df

Please sign in to comment.