Skip to content

Commit

Permalink
dev: improve devcontainer env
Browse files Browse the repository at this point in the history
  • Loading branch information
sgtoj committed Aug 3, 2023
1 parent 04f91d5 commit 3e89f78
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
41 changes: 22 additions & 19 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
FROM mcr.microsoft.com/vscode/devcontainers/base:1-focal

# Install AWS CLI
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 aws
RUN SYSTEM_ARCH=$(uname -m) \
&& curl "https://awscli.amazonaws.com/awscli-exe-linux-${SYSTEM_ARCH}.zip" -o "awscliv2.zip" \
&& unzip awscliv2.zip \
&& aws/install \
&& aws --version \
&& rm -rf aws

# 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 \
Expand Down
7 changes: 6 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-cognito-custom-message-sender/.devcontainer/tmp/.terraform.d/"
"TF_PLUGIN_CACHE_DIR": "${containerWorkspaceFolder}/.devcontainer/tmp/.terraform.d/"
},
"customizations": {
"vscode": {
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ following tools:
1. Clone this repository:

```bash
git clone https://github.com/cruxstack/terraform-docker-artifact-packager.git
git clone https://github.com/cruxstack/terraform-aws-cognito-custom-message-sender.git
code terraform-aws-cognito-custom-message-sender
```

Expand Down

0 comments on commit 3e89f78

Please sign in to comment.