Skip to content

Commit

Permalink
fixup devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
baolsen committed Nov 27, 2024
1 parent a4b7ec8 commit 5c07c5a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
// Update 'VARIANT' to pick an Ubuntu version: jammy / ubuntu-22.04, focal / ubuntu-20.04, bionic /ubuntu-18.04
// Use ubuntu-22.04 or ubuntu-18.04 on local arm64/Apple Silicon.
"args": {
"VARIANT": "ubuntu-22.04"
"TAG": "latest",
"USER": "vscode"
}
},

Expand Down
4 changes: 3 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ Please note we have a code of conduct, please follow it in all your interactions
1. Update the README.md with details of changes including example hcl blocks and [example files](./examples) if appropriate.
2. Add appropriate tests.
3. Run pre-commit hooks `pre-commit run -a`.
4. Once all outstanding comments and checklist items have been addressed, your contribution will be merged! Merged PRs will be included in the next release. The terraform-aws-vpc maintainers take care of updating the CHANGELOG as they merge.
4. Once all outstanding comments and checklist items have been addressed, your contribution will be merged!

Merged PRs will be included in the next release.

## Checklists for contributions

Expand Down
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"ms-vscode-remote.remote-containers"
]
}
40 changes: 27 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/ubuntu/.devcontainer/base.Dockerfile
# Docker image for executing Terraform static code analysis tools and pre-commit hooks
# This may be run as a devcontainer in VSCode or as a standalone container for tests
# Inspired by https://github.com/alastairhm/docker-terraform-check

# [Choice] Ubuntu version (use ubuntu-22.04 or ubuntu-18.04 on local arm64/Apple Silicon): ubuntu-22.04, ubuntu-20.04, ubuntu-18.04
ARG VARIANT="jammy"
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}
ARG TAG=latest

# Install additional OS packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends python3 python3-pip cloud-init
FROM ubuntu:${TAG} as this

ARG USER=user

COPY requirements.txt .
RUN pip install -r requirements.txt
ARG TFSEC_VER=v1.28.1
ARG TFLINT_VER=v0.43.0
ARG TFDOCS_VER=v0.19.0

COPY .pre-commit-config.yaml .
RUN git init . && pre-commit install-hooks
# Install additional OS packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && \
apt-get -y install --no-install-recommends \
bash ca-certificates wget git unzip tar python3 python3-venv && \
update-ca-certificates -f

# Install Terraform static code analysis tools.
COPY .tflint.hcl .
COPY .tfsec-config.yml .
COPY .tfdocs-config.yml .
ADD https://github.com/terraform-docs/terraform-docs/releases/download/v0.16.0/terraform-docs-v0.16.0-linux-amd64.tar.gz ./terraform-docs.tar.gz
RUN tar -xzf terraform-docs.tar.gz && chmod +x terraform-docs && mv terraform-docs /usr/local/bin/terraform-docs
RUN wget https://github.com/aquasecurity/tfsec/releases/download/${TFSEC_VER}/tfsec-linux-amd64 -O /usr/bin/tfsec && chmod +x /usr/bin/tfsec && \
wget https://github.com/terraform-linters/tflint/releases/download/${TFLINT_VER}/tflint_linux_amd64.zip && unzip tflint_linux_amd64.zip && mv tflint /usr/bin && rm tflint_linux_amd64.zip && \
tflint --config .tflint.hcl --init && \
wget https://github.com/terraform-docs/terraform-docs/releases/download/${TFDOCS_VER}/terraform-docs-${TFDOCS_VER}-linux-amd64.tar.gz -O terraform-docs.tar.gz && \
tar -xzf terraform-docs.tar.gz && chmod +x terraform-docs && mv terraform-docs /usr/bin && rm terraform-docs.tar.gz

# For dev container in VSCode, create a non-root user.
RUN useradd -ms /bin/bash ${USER}
USER ${USER}

0 comments on commit 5c07c5a

Please sign in to comment.