kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/release/cloudbuild/pre-commit/Dockerfile (about) 1 # Copyright 2020 The Kythe Authors. All rights reserved. 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 # docker build -t gcr.io/kythe-repo/pre-commit . 16 FROM gcr.io/kythe-repo/bazelisk-builder-client:latest 17 18 RUN apt-get update \ 19 && apt-get upgrade -y \ 20 && apt-get install -y --no-install-recommends \ 21 curl ca-certificates \ 22 # pre-commit dependencies 23 python3 python3-dev python3-pip python3-venv \ 24 # Linter dependencies 25 golang-1.19-go shellcheck clang-format-14 openjdk-11-jre-headless git \ 26 && apt-get clean \ 27 && rm -rf /var/lib/apt/lists/* 28 29 # Make clang-format-14 the default 30 RUN update-alternatives \ 31 --install /usr/bin/clang-format clang-format /usr/bin/clang-format-14 100 32 33 # Make go-1.19 the default 34 RUN update-alternatives \ 35 --install /usr/bin/go go /usr/lib/go-1.19/bin/go 100 36 RUN update-alternatives \ 37 --install /usr/bin/gofmt gofmt /usr/lib/go-1.19/bin/gofmt 100 38 39 # Install pip-packages 40 COPY requirements.txt pre-commit-requirements.txt 41 RUN python3 -m venv /tmp/venv 42 RUN /tmp/venv/bin/pip3 install --require-hashes -r pre-commit-requirements.txt \ 43 && rm pre-commit-requirements.txt 44 45 # Install extra linters 46 RUN go install github.com/bazelbuild/buildtools/buildifier@latest \ 47 && go install golang.org/x/lint/golint@latest \ 48 && go install honnef.co/go/tools/cmd/staticcheck@latest 49 50 # Fetch the latest version of google-java-format from GitHub 51 RUN curl -s https://api.github.com/repos/google/google-java-format/releases/latest \ 52 | sed -n '/browser_download_url/s/[^:]*:[^"]*\("[^"]*"\).*/url = \1/p' \ 53 | egrep 'google-java-format-[^-]*-all-deps.jar' \ 54 | curl -L -o /usr/bin/google-java-format.jar -K - \ 55 && /bin/echo -e '#!/bin/sh\nexec java -jar /usr/bin/google-java-format.jar "$@"' >/usr/bin/google-java-format \ 56 && chmod +x /usr/bin/google-java-format 57 58 # Install go wrapper script 59 ADD go /usr/local/bin/go 60 ENV PATH=$PATH:/root/go/bin:$CARGO_HOME/bin 61 ENTRYPOINT ["/tmp/venv/bin/pre-commit"]