From 470649c691eb3a28058666d0a327e212016dd7d9 Mon Sep 17 00:00:00 2001 From: tiulpin Date: Mon, 4 Sep 2023 23:21:31 +0200 Subject: [PATCH] QD-4594 Set up contributing guide and `bake` for fast local builds --- .github/workflows/ci.yml | 2 +- 2023.2/android-community/Dockerfile | 4 +++- 2023.2/dotnet/Dockerfile | 7 +++--- 2023.2/go/Dockerfile | 7 +++--- 2023.2/js/Dockerfile | 6 ++--- 2023.2/jvm-community/Dockerfile | 4 +++- 2023.2/jvm/Dockerfile | 12 +++++----- 2023.2/php/Dockerfile | 19 ++++++++-------- 2023.2/python-community/Dockerfile | 4 +++- 2023.2/python/Dockerfile | 12 +++++----- 2023.2/run-tests.sh | 8 ------- CONTRIBUTING.md | 35 +++++++++++++++++++++++++++++ docker-bake.hcl | 25 +++++++++++++++++++++ 13 files changed, 103 insertions(+), 42 deletions(-) delete mode 100755 2023.2/run-tests.sh create mode 100644 CONTRIBUTING.md create mode 100644 docker-bake.hcl diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bc1ccd90..a4c54ac2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 # - name: Hadolint # uses: hadolint/hadolint-action@v3.1.0 # with: diff --git a/2023.2/android-community/Dockerfile b/2023.2/android-community/Dockerfile index 097943fb..81adefe5 100644 --- a/2023.2/android-community/Dockerfile +++ b/2023.2/android-community/Dockerfile @@ -1,4 +1,6 @@ ARG BASE_TAG="bullseye-slim" +ARG NODE_TAG="16-bullseye-slim" +FROM node:$NODE_TAG AS node_base FROM debian:$BASE_TAG ENV HOME="/root" \ @@ -32,8 +34,8 @@ RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \ ENV GRADLE_USER_HOME="/data/cache/gradle" -ARG QD_BUILD="QDANDC-2023.2" ARG QD_RELEASE="2023.2" +ARG QD_BUILD="QDANDC-$QD_RELEASE" # hadolint ignore=DL3003,SC2043 RUN set -ex && \ dpkgArch="$(dpkg --print-architecture)" && \ diff --git a/2023.2/dotnet/Dockerfile b/2023.2/dotnet/Dockerfile index ea15950b..a2b38ff2 100644 --- a/2023.2/dotnet/Dockerfile +++ b/2023.2/dotnet/Dockerfile @@ -1,8 +1,7 @@ ARG NODE_TAG="16-bullseye-slim" -ARG BASE_TAG="6.0-bullseye-slim" - +ARG DOTNET_BASE_TAG="6.0-bullseye-slim" FROM node:$NODE_TAG AS node_base -FROM mcr.microsoft.com/dotnet/sdk:$BASE_TAG +FROM mcr.microsoft.com/dotnet/sdk:$DOTNET_BASE_TAG ENV HOME="/root" \ LC_ALL="en_US.UTF-8" \ @@ -63,8 +62,8 @@ RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \ npm install -g eslint@v8.47.0 pnpm@v8.7.1 && npm config set update-notifier false && \ chmod 777 -R "$HOME/.npm" "$HOME/.npmrc" -ARG QD_BUILD="QDNET-2023.2" ARG QD_RELEASE="2023.2" +ARG QD_BUILD="QDNET-$QD_RELEASE" # hadolint ignore=DL3003,SC2043 RUN set -ex && \ dpkgArch="$(dpkg --print-architecture)" && \ diff --git a/2023.2/go/Dockerfile b/2023.2/go/Dockerfile index c70a5017..95c3b844 100644 --- a/2023.2/go/Dockerfile +++ b/2023.2/go/Dockerfile @@ -1,8 +1,7 @@ +ARG GO_TAG="1.19-bullseye" ARG NODE_TAG="16-bullseye-slim" -ARG BASE_TAG="1.19-bullseye" - FROM node:$NODE_TAG AS node_base -FROM golang:$BASE_TAG +FROM golang:$GO_TAG ENV HOME="/root" \ LC_ALL="en_US.UTF-8" \ @@ -47,8 +46,8 @@ RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \ npm install -g eslint@v8.47.0 pnpm@v8.7.1 && npm config set update-notifier false && \ chmod 777 -R "$HOME/.npm" "$HOME/.npmrc" -ARG QD_BUILD="QDGO-2023.2" ARG QD_RELEASE="2023.2" +ARG QD_BUILD="QDGO-$QD_RELEASE" # hadolint ignore=DL3003,SC2043 RUN set -ex && \ dpkgArch="$(dpkg --print-architecture)" && \ diff --git a/2023.2/js/Dockerfile b/2023.2/js/Dockerfile index bd023b2f..40be78aa 100644 --- a/2023.2/js/Dockerfile +++ b/2023.2/js/Dockerfile @@ -1,5 +1,5 @@ -ARG BASE_TAG="16-bullseye-slim" -FROM node:$BASE_TAG +ARG NODE_TAG="16-bullseye-slim" +FROM node:$NODE_TAG ENV HOME="/root" \ LC_ALL="en_US.UTF-8" \ @@ -34,8 +34,8 @@ RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \ ENV PATH="/opt/yarn/bin:$PATH" -ARG QD_BUILD="QDJVM-2023.2" ARG QD_RELEASE="2023.2" +ARG QD_BUILD="QDJVM-$QD_RELEASE" # hadolint ignore=DL3003,SC2043 RUN set -ex && \ dpkgArch="$(dpkg --print-architecture)" && \ diff --git a/2023.2/jvm-community/Dockerfile b/2023.2/jvm-community/Dockerfile index 8e6de177..88cf374a 100644 --- a/2023.2/jvm-community/Dockerfile +++ b/2023.2/jvm-community/Dockerfile @@ -1,4 +1,6 @@ ARG BASE_TAG="bullseye-slim" +ARG NODE_TAG="16-bullseye-slim" +FROM node:$NODE_TAG AS node_base FROM debian:$BASE_TAG ENV HOME="/root" \ @@ -32,8 +34,8 @@ RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \ ENV GRADLE_USER_HOME="/data/cache/gradle" -ARG QD_BUILD="QDJVMC-2023.2" ARG QD_RELEASE="2023.2" +ARG QD_BUILD="QDJVMC-$QD_RELEASE" # hadolint ignore=DL3003,SC2043 RUN set -ex && \ dpkgArch="$(dpkg --print-architecture)" && \ diff --git a/2023.2/jvm/Dockerfile b/2023.2/jvm/Dockerfile index 1ad5f768..17dba4f2 100644 --- a/2023.2/jvm/Dockerfile +++ b/2023.2/jvm/Dockerfile @@ -1,4 +1,6 @@ ARG BASE_TAG="bullseye-slim" +ARG NODE_TAG="16-bullseye-slim" +FROM node:$NODE_TAG AS node_base FROM debian:$BASE_TAG ENV HOME="/root" \ @@ -31,10 +33,10 @@ RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \ git config --global --add safe.directory '*' ENV PATH="/opt/yarn/bin:$PATH" -COPY --from=node:16-bullseye-slim /usr/local/bin/node /usr/local/bin/ -COPY --from=node:16-bullseye-slim /usr/local/include/node /usr/local/include/node -COPY --from=node:16-bullseye-slim /usr/local/lib/node_modules /usr/local/lib/node_modules -COPY --from=node:16-bullseye-slim /opt/yarn-* /opt/yarn/ +COPY --from=node_base /usr/local/bin/node /usr/local/bin/ +COPY --from=node_base /usr/local/include/node /usr/local/include/node +COPY --from=node_base /usr/local/lib/node_modules /usr/local/lib/node_modules +COPY --from=node_base /opt/yarn-* /opt/yarn/ RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \ ln -s /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx && \ ln -s /usr/local/lib/node_modules/corepack/dist/corepack.js /usr/local/bin/corepack && \ @@ -46,8 +48,8 @@ RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \ ENV GRADLE_USER_HOME="/data/cache/gradle" -ARG QD_BUILD="QDJVM-2023.2" ARG QD_RELEASE="2023.2" +ARG QD_BUILD="QDJVM-$QD_RELEASE" # hadolint ignore=DL3003,SC2043 RUN set -ex && \ dpkgArch="$(dpkg --print-architecture)" && \ diff --git a/2023.2/php/Dockerfile b/2023.2/php/Dockerfile index e8a62e4d..7145df4f 100644 --- a/2023.2/php/Dockerfile +++ b/2023.2/php/Dockerfile @@ -1,8 +1,9 @@ ARG NODE_TAG="16-bullseye-slim" -ARG BASE_TAG="8.1-cli-bullseye" - +ARG PHP_TAG="8.1-cli-bullseye" +ARG COMPOSER_TAG="2.5.1" FROM node:$NODE_TAG AS node_base -FROM php:$BASE_TAG +FROM composer:$COMPOSER_TAG AS composer_base +FROM php:$PHP_TAG ENV HOME="/root" \ LC_ALL="en_US.UTF-8" \ @@ -35,10 +36,10 @@ RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \ git config --global --add safe.directory '*' ENV PATH="/opt/yarn/bin:$PATH" -COPY --from=node:16-bullseye-slim /usr/local/bin/node /usr/local/bin/ -COPY --from=node:16-bullseye-slim /usr/local/include/node /usr/local/include/node -COPY --from=node:16-bullseye-slim /usr/local/lib/node_modules /usr/local/lib/node_modules -COPY --from=node:16-bullseye-slim /opt/yarn-* /opt/yarn/ +COPY --from=node_base /usr/local/bin/node /usr/local/bin/ +COPY --from=node_base /usr/local/include/node /usr/local/include/node +COPY --from=node_base /usr/local/lib/node_modules /usr/local/lib/node_modules +COPY --from=node_base /opt/yarn-* /opt/yarn/ RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \ ln -s /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx && \ ln -s /usr/local/lib/node_modules/corepack/dist/corepack.js /usr/local/bin/corepack && \ @@ -48,10 +49,10 @@ RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \ npm install -g eslint@v8.47.0 pnpm@v8.7.1 && npm config set update-notifier false && \ chmod 777 -R "$HOME/.npm" "$HOME/.npmrc" -COPY --from=composer:2.5.1 /usr/bin/composer /usr/bin/composer +COPY --from=composer_base /usr/bin/composer /usr/bin/composer -ARG QD_BUILD="QDPHP-2023.2" ARG QD_RELEASE="2023.2" +ARG QD_BUILD="QDPHP-$QD_RELEASE" # hadolint ignore=DL3003,SC2043 RUN set -ex && \ dpkgArch="$(dpkg --print-architecture)" && \ diff --git a/2023.2/python-community/Dockerfile b/2023.2/python-community/Dockerfile index adc6bccb..a0b65fbe 100644 --- a/2023.2/python-community/Dockerfile +++ b/2023.2/python-community/Dockerfile @@ -1,4 +1,6 @@ ARG BASE_TAG="bullseye-slim" +ARG NODE_TAG="16-bullseye-slim" +FROM node:$NODE_TAG AS node_base FROM debian:$BASE_TAG ENV HOME="/root" \ @@ -70,8 +72,8 @@ RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \ ${CONDA_DIR}/bin/conda install -c conda-forge poetry pipenv && ${CONDA_DIR}/bin/conda clean -afy && \ rm -rf /tmp/* -ARG QD_BUILD="QDPYC-2023.2" ARG QD_RELEASE="2023.2" +ARG QD_BUILD="QDPYC-$QD_RELEASE" # hadolint ignore=DL3003,SC2043 RUN set -ex && \ dpkgArch="$(dpkg --print-architecture)" && \ diff --git a/2023.2/python/Dockerfile b/2023.2/python/Dockerfile index 2bfda942..c7807dbf 100644 --- a/2023.2/python/Dockerfile +++ b/2023.2/python/Dockerfile @@ -1,4 +1,6 @@ ARG BASE_TAG="bullseye-slim" +ARG NODE_TAG="16-bullseye-slim" +FROM node:$NODE_TAG AS node_base FROM debian:$BASE_TAG ENV HOME="/root" \ @@ -71,10 +73,10 @@ RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \ rm -rf /tmp/* ENV PATH="/opt/yarn/bin:$PATH" -COPY --from=node:16-bullseye-slim /usr/local/bin/node /usr/local/bin/ -COPY --from=node:16-bullseye-slim /usr/local/include/node /usr/local/include/node -COPY --from=node:16-bullseye-slim /usr/local/lib/node_modules /usr/local/lib/node_modules -COPY --from=node:16-bullseye-slim /opt/yarn-* /opt/yarn/ +COPY --from=node_base /usr/local/bin/node /usr/local/bin/ +COPY --from=node_base /usr/local/include/node /usr/local/include/node +COPY --from=node_base /usr/local/lib/node_modules /usr/local/lib/node_modules +COPY --from=node_base /opt/yarn-* /opt/yarn/ RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \ ln -s /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx && \ ln -s /usr/local/lib/node_modules/corepack/dist/corepack.js /usr/local/bin/corepack && \ @@ -84,8 +86,8 @@ RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \ npm install -g eslint@v8.47.0 pnpm@v8.7.1 && npm config set update-notifier false && \ chmod 777 -R "$HOME/.npm" "$HOME/.npmrc" -ARG QD_BUILD="QDPY-2023.2" ARG QD_RELEASE="2023.2" +ARG QD_BUILD="QDPY-$QD_RELEASE" # hadolint ignore=DL3003,SC2043 RUN set -ex && \ dpkgArch="$(dpkg --print-architecture)" && \ diff --git a/2023.2/run-tests.sh b/2023.2/run-tests.sh deleted file mode 100755 index 2a846246..00000000 --- a/2023.2/run-tests.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash -set -e -# basic sanity tests that check that an image can be built from Dockerfile and run, all linter options printed - -for dir in */; do - echo "Testing $dir" - (cd "$dir" && docker buildx build -t qodana:dev . && docker run --rm -it qodana:dev -h ) -done diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..36b8760a --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,35 @@ +# Contributing + +By participating in this project, you agree to abide our [Code of conduct](.github/CODE_OF_CONDUCT.md). + +## Set up your machine + +Prerequisites: + +- [Docker](https://docs.docker.com/get-docker/) + +Other things you might need to develop: + +- [IntelliJ IDEA](https://www.jetbrains.com/idea/) (it's [free for open-source development](https://www.jetbrains.com/community/opensource/)) + +Clone the project anywhere: + +```sh +git clone git@github.com:JetBrains/qodana-docker.git +``` + +`cd` into the directory, with [Docker Bake](https://docs.docker.com/build/bake/) you can build all images at once: + +```shell +docker buildx bake +``` + +## Create a commit + +Commit messages should be well formatted, and to make that "standardized", we are using [internal issue tracker](https://youtrack.jetbrains.com) references. + + +## Submit a pull request + +Push your branch to your repository fork and open a pull request against the +main branch. diff --git a/docker-bake.hcl b/docker-bake.hcl new file mode 100644 index 00000000..bcf3573d --- /dev/null +++ b/docker-bake.hcl @@ -0,0 +1,25 @@ +group "default" { + targets = ["232"] +} + +target "232" { + name = "qodana-${edition}" + matrix = { + edition = ["android-community", "dotnet", "go", "js", "jvm", "jvm-community", "php", "python", "python-community"] + version = ["2023.2"] + } + args = { + QD_RELEASE = "2023.2" + BASE_TAG = "bullseye-slim" + DOTNET_TAG = "6.0-bullseye-slim" + GO_TAG = "1.19-bullseye" + NODE_TAG = "16-bullseye-slim" + PHP_TAG = "8.1-cli-bullseye" + COMPOSER_TAG="2.5.1" + } + tags = [ + "docker.io/jetbrains/qodana:${edition}-${version}-latest" + ] +# platforms = ["linux/amd64", "linux/arm64"] // uncomment to build for multiple platforms, but it will take more time + dockerfile = "${version}/${edition}/Dockerfile" +} \ No newline at end of file