Skip to content

Commit

Permalink
dev: refactor devcontainer and mount aws config from host for devcont…
Browse files Browse the repository at this point in the history
…ainer
  • Loading branch information
sgtoj committed Jul 31, 2023
1 parent 8dc3bb7 commit 08c7108
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
24 changes: 12 additions & 12 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -33,6 +36,7 @@
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig",
"github.copilot",
"github.copilot-chat",
"github.vscode-github-actions",
"hashicorp.terraform",
"ms-azuretools.vscode-docker",
Expand Down

0 comments on commit 08c7108

Please sign in to comment.