-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
37 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"recommendations": [ | ||
"ms-vscode-remote.remote-containers" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |