From 08c7108093bde9adc99c727d99472f8ce1e077aa Mon Sep 17 00:00:00 2001 From: Brian Ojeda <9335829+sgtoj@users.noreply.github.com> Date: Mon, 31 Jul 2023 19:31:19 +0000 Subject: [PATCH] dev: refactor devcontainer and mount aws config from host for devcontainer --- .devcontainer/Dockerfile | 24 ++++++++++++------------ .devcontainer/devcontainer.json | 6 +++++- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index a690a85..68e9a2d 100755 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,32 +1,32 @@ 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 Python Packages -RUN python3 -m pip install \ - boto3 \ - black - -# 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 -# Verify Installs +# install docker +COPY --from=docker:dind /usr/local/bin/docker /usr/local/bin/ + +# install python packages +RUN python3 -m pip install \ + boto3 \ + black + +# verify installs RUN terraform --version \ && aws --version \ && docker --version diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b48e767..96dc8eb 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-s3-zip-uploader/.devcontainer/tmp/.terraform.d/" + "TF_PLUGIN_CACHE_DIR": "${containerWorkspaceFolder}/.devcontainer/tmp/.terraform.d/" }, "customizations": { "vscode": { @@ -33,6 +36,7 @@ "dbaeumer.vscode-eslint", "editorconfig.editorconfig", "github.copilot", + "github.copilot-chat", "github.vscode-github-actions", "hashicorp.terraform", "ms-azuretools.vscode-docker",