Skip to content

Commit

Permalink
chore: support for Docker in VS Code devcontainer (#21909)
Browse files Browse the repository at this point in the history
The current devcontainer configuration doesn't support docker commands.

More details in this Slack Thread: https://cdk-dev.slack.com/archives/C018XT6REKT/p1661980670194059

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)


*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
mrgrain authored Oct 25, 2022
1 parent e28b82f commit b22182f
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 11 deletions.
9 changes: 0 additions & 9 deletions .devcontainer.json

This file was deleted.

19 changes: 19 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM jsii/superchain:1-buster-slim

USER root

# Change uid/guid of superchain so it can work with the docker-in-docker feature
RUN groupmod --gid 1000 superchain \
&& usermod --uid 1000 --gid 1000 superchain \
&& chown -R 1000:1000 /home/superchain

USER superchain

# Setup oh-my-zsh
RUN sudo apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& sudo apt-get -y install --no-install-recommends zsh vim \
&& sudo rm -rf /var/lib/apt/lists/* \
&& sudo chsh -s $(which zsh) $(whoami)
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended \
# Required, otherwise shell is extermly slow due the size of the aws-cdk
&& sudo sh -c 'echo "[oh-my-zsh]\n hide-dirty = 1" > /etc/gitconfig'
21 changes: 21 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "aws-cdk",
"build": {
"dockerfile": "Dockerfile"
},

"customizations": {
"vscode": {
"extensions": ["dbaeumer.vscode-eslint"]
}
},

"postCreateCommand": "yarn install",
"remoteUser": "superchain",
"features": {
"docker-in-docker": {
"version": "latest",
"moby": true
}
}
}
13 changes: 11 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ This document describes how to set up a development environment and submit your
let us know if it's not up-to-date (even better, submit a PR with your corrections ;-)).

- [Getting Started](#getting-started)
- [Local setup](#setup)
- [Dev Container](#dev-container)
- [Pull Requests](#pull-requests)
- [Step 1: Find something to work on](#step-1-find-something-to-work-on)
- [Step 2: Design (optional)](#step-2-design)
Expand All @@ -23,7 +25,7 @@ let us know if it's not up-to-date (even better, submit a PR with your correcti
- [Breaking Changes](#breaking-changes)
- [Documentation](#documentation)
- [Rosetta](#rosetta)
- [Tools](#tools)
- [Tools](#tools-advanced)
- [Linters](#linters)
- [cfn2ts](#cfn2ts)
- [scripts/foreach.sh](#scriptsforeachsh)
Expand Down Expand Up @@ -147,7 +149,14 @@ docker$ exit

The `dist/` folder within each module contains the packaged up language artifacts.

## Gitpod (Alternative)
### Dev Container

The AWS CDK provides a VS Code Dev Container with all dependencies pre-installed.
Please follow the [setup instructions](https://code.visualstudio.com/docs/remote/containers-tutorial) to configure VS Code.

With VS Code setup, you will be prompted to open the `aws-cdk` repo in a Dev Container, or you can choos "Dev Containers: Reopen in Container" from the VS Code command palette.

### Gitpod (Alternative)

You may also set up your local development environment using [Gitpod](http://gitpod.io) -
a service that allows you to spin up an in-browser Visual Studio Code-compatible editor,
Expand Down

0 comments on commit b22182f

Please sign in to comment.