From 2d29ac576f65f77bf4f254d8b5998b10e7fa4ac9 Mon Sep 17 00:00:00 2001 From: kjeld Schouten-Lebbing Date: Tue, 28 Sep 2021 15:11:33 +0200 Subject: [PATCH] fix the devcontainer --- .devcontainer/Dockerfile | 99 +++++++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 33 +++++++++++ .gitignore | 1 - 3 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000000..180b1f7b64e --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,99 @@ +# [Choice] Ruby version: 2, 2.7, 2.6, 2.5 +ARG VARIANT="2" + +# hadolint ignore=DL3007 +FROM quay.io/helmpack/chart-releaser:v1.2.1 AS cr + +# hadolint ignore=DL3007 +FROM jnorwood/helm-docs:v1.5.0 AS hd + +# hadolint ignore=DL3007 +FROM quay.io/git-chglog/git-chglog:0.15.0 AS gcl + +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.154.0/containers/ruby/.devcontainer/base.Dockerfile +FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT} + +ARG HELM_VERSION="3.5.4" +ARG CT_VERSION=3.3.1 +ENV DEBIAN_FRONTEND=noninteractive +ENV PYTHONUNBUFFERED 1 + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +# hadolint ignore=DL3008,DL3015,SC2086,SC2155 +RUN --mount=type=bind,from=cr,source=/usr/local/bin,target=/crbin \ + cp /crbin/cr /usr/local/bin/cr + +# hadolint ignore=DL3008,DL3015,SC2086,SC2155 +RUN --mount=type=bind,from=hd,source=/usr/bin/,target=/hdbin \ + cp /hdbin/helm-docs /usr/local/bin/helm-docs + +# hadolint ignore=DL3008,DL3015,SC2086,SC2155 +RUN --mount=type=bind,from=gcl,source=/usr/local/bin,target=/gclbin \ + cp /gclbin/git-chglog /usr/local/bin/git-chglog + +RUN \ + apt-get update \ + && \ + apt-get -y install --no-install-recommends \ + libonig-dev \ + gnupg2 \ + libjq \ + libjq-dev \ + python3-pip \ + python3-setuptools \ + debhelper-compat \ + dh-python \ + python3-dev \ + devscripts \ + python3-jsonschema \ + python3-semantic-version \ + python3-kubernetes \ + python3-yaml \ + && \ + sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin \ + && \ + curl -o /tmp/helm.tar.gz "https://get.helm.sh/helm-v${HELM_VERSION}-linux-$(dpkg --print-architecture).tar.gz" \ + && tar xvzf /tmp/helm.tar.gz -C /usr/local/bin --strip-components 1 "linux-$(dpkg --print-architecture)/helm" \ + && chmod +x /usr/local/bin/helm \ + && \ + curl -o /tmp/ct.tar.gz -L "https://github.com/helm/chart-testing/releases/download/v${CT_VERSION}/chart-testing_${CT_VERSION}_linux_$(dpkg --print-architecture).tar.gz" \ + && mkdir -p /etc/ct \ + && tar xvzf /tmp/ct.tar.gz -C /usr/local/bin "ct" \ + && tar xvzf /tmp/ct.tar.gz --strip-components=1 -C /etc/ct "etc/" \ + && chmod +x /usr/local/bin/ct \ + && \ + pip3 install \ + pre-commit \ + yamale \ + yamllint \ + && \ + mkdir /tmp/precommit/ && \ + cd /tmp && \ + wget https://raw.githubusercontent.com/truecharts/apps/master/Gemfile && \ + cd - && \ + cd /tmp/precommit && \ + wget https://raw.githubusercontent.com/truecharts/apps/master/.pre-commit-config.yaml && \ + git init . && \ + pre-commit install-hooks && \ + echo "installed pre-commit hooks:" && \ + ls ~/.cache/pre-commit/* \ + && \ + bundle config set system 'true' \ + && bundle install --gemfile /tmp/Gemfile \ + && \ + cd /tmp && \ + git clone https://github.com/truenas/catalog_validation.git && \ + cd - && \ + cd /tmp/catalog_validation && \ + git checkout $(git describe --tags $(git rev-list --tags --max-count=1)) && \ + pip install -U . && \ + cd - && \ + rm -Rf \ + /tmp/Gemfile \ + /tmp/Gemfile.lock \ + /tmp/helm.tar.gz \ + /tmp/ct.tar.gz \ + /tmp/catalog_validation \ + /tmp/precommit \ + || true diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000000..8b7c541d374 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,33 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.154.0/containers/ruby +{ + "name": "Ruby", + "build": { + "context": "..", + "dockerfile": "Dockerfile", + "args": { + // Update 'VARIANT' to pick a Ruby version: 2, 2.7, 2.6, 2.5 + "VARIANT": "2.7", + } + }, + + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-kubernetes-tools.vscode-kubernetes-tools", + "rebornix.Ruby" + ], + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "export RUBYJQ_USE_SYSTEM_LIBRARIES=1 && bundle install", + + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode" +} diff --git a/.gitignore b/.gitignore index 4d5d3418783..1d0b3ca23b5 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,6 @@ auto_config.py # IDE resources .vscode .idea -.devcontainer/ Gemfile.lock .ignore/ /docs/api/_build/