From 262de29e5871c1c67fe5e156ebb5c8a7ad8c92bf Mon Sep 17 00:00:00 2001 From: Brian Ojeda <9335829+sgtoj@users.noreply.github.com> Date: Mon, 31 Jul 2023 19:57:09 +0000 Subject: [PATCH] dev: improve devcontainer env --- .devcontainer/Dockerfile | 32 +++++++++++++++++--------------- .devcontainer/devcontainer.json | 7 ++++++- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 93638c6..25c0a71 100755 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,37 +1,39 @@ -FROM mcr.microsoft.com/devcontainers/base:jammy +FROM mcr.microsoft.com/vscode/devcontainers/base:1-focal -# Install AWS CLI +# install aws RUN apt-get update && \ apt-get install -y unzip python3-pip && \ pip3 install --no-cache-dir --upgrade awscli && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* -# Install Node.js -ENV NODE_VERSION=18.x -RUN curl -sL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - && \ - apt-get install -y nodejs && \ - npm install -g typescript - -# Install Docker CLI -COPY --from=docker:dind /usr/local/bin/docker /usr/local/bin/ - -# Install Terraform +# install terraform ENV TERRAFORM_VERSION=1.5.1 ENV TF_PLUGIN_CACHE_DIR=$HOME/.terraform.d/plugin-cache +RUN mkdir -p $TF_PLUGIN_CACHE_DIR RUN SYSTEM_ARCH=$(dpkg --print-architecture) \ - && mkdir -p $TF_PLUGIN_CACHE_DIR \ && curl -OL https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_${SYSTEM_ARCH}.zip \ && unzip terraform_${TERRAFORM_VERSION}_linux_${SYSTEM_ARCH}.zip \ && mv terraform /usr/local/bin/ \ && terraform version \ && rm terraform_${TERRAFORM_VERSION}_linux_${SYSTEM_ARCH}.zip -# Install Open Policy Agent +# install docker +COPY --from=docker:dind /usr/local/bin/docker /usr/local/bin/ + +# install node.js +ENV NODE_VERSION=18.x +RUN curl -sL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - && \ + apt-get install -y nodejs + +# install typescript +RUN npm install -g typescript + +# install opa RUN wget https://github.com/open-policy-agent/opa/releases/latest/download/opa_linux_amd64 -O /usr/local/bin/opa && \ chmod +x /usr/local/bin/opa -# Verify Installs +# verify installs RUN terraform --version \ && aws --version \ && node --version \ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index eeb6c75..79793ec 100755 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,8 +4,11 @@ "features": { "ghcr.io/devcontainers/features/docker-in-docker:2.0.1": {}, }, + "mounts": [ + "source=${localEnv:HOME}/.aws,target=/home/vscode/.aws,type=bind,consistency=cached" + ], "containerEnv": { - "TF_PLUGIN_CACHE_DIR": "/workspaces/terraform-aws-cloudfront-middleware-at-edge/.devcontainer/tmp/.terraform.d/" + "TF_PLUGIN_CACHE_DIR": "${containerWorkspaceFolder}/.devcontainer/tmp/.terraform.d/" }, "customizations": { "vscode": { @@ -28,7 +31,9 @@ "dbaeumer.vscode-eslint", "editorconfig.editorconfig", "github.copilot", + "github.copilot-chat", "github.vscode-github-actions", + "github.vscode-pull-request-github", "hashicorp.terraform", "ms-azuretools.vscode-docker", "tsandall.opa",