Fix cleanup sonarqube findings (#2106)

* fix: update dockerignore and gitignore to exclude sonarqube work dir

Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com>

* fix: remove useless equality check

Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com>

* fix: use sonarqube Dockerfile recommendations

Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com>

---------

Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com>
This commit is contained in:
cryptk 2024-04-23 11:43:00 -05:00 committed by GitHub
parent 8e36fe9b6f
commit 3411e072ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 31 additions and 26 deletions

View File

@ -6,3 +6,6 @@ examples/chatbot-ui/models
examples/rwkv/models examples/rwkv/models
examples/**/models examples/**/models
Dockerfile* Dockerfile*
# SonarQube
.scannerwork

3
.gitignore vendored
View File

@ -44,3 +44,6 @@ prepare
*.pb.go *.pb.go
*pb2.py *pb2.py
*pb2_grpc.py *pb2_grpc.py
# SonarQube
.scannerwork

View File

@ -3,7 +3,7 @@ ARG BASE_IMAGE=ubuntu:22.04
ARG GRPC_BASE_IMAGE=${BASE_IMAGE} ARG GRPC_BASE_IMAGE=${BASE_IMAGE}
# extras or core # extras or core
FROM ${BASE_IMAGE} as requirements-core FROM ${BASE_IMAGE} AS requirements-core
USER root USER root
@ -24,7 +24,7 @@ RUN apt-get update && \
apt-get install -y ca-certificates curl python3-pip unzip && apt-get clean apt-get install -y ca-certificates curl python3-pip unzip && apt-get clean
# Install Go # Install Go
RUN curl -L -s https://go.dev/dl/go$GO_VERSION.linux-$TARGETARCH.tar.gz | tar -C /usr/local -xz RUN curl -L -s https://go.dev/dl/go${GO_VERSION}.linux-${TARGETARCH}.tar.gz | tar -C /usr/local -xz
ENV PATH $PATH:/usr/local/go/bin ENV PATH $PATH:/usr/local/go/bin
# Install grpc compilers # Install grpc compilers
@ -80,7 +80,7 @@ RUN test -n "$TARGETARCH" \
################################### ###################################
################################### ###################################
FROM requirements-core as requirements-extras FROM requirements-core AS requirements-extras
RUN apt install -y gpg && \ RUN apt install -y gpg && \
curl https://repo.anaconda.com/pkgs/misc/gpgkeys/anaconda.asc | gpg --dearmor > conda.gpg && \ curl https://repo.anaconda.com/pkgs/misc/gpgkeys/anaconda.asc | gpg --dearmor > conda.gpg && \
@ -105,7 +105,7 @@ RUN if [ ! -e /usr/bin/python ]; then \
################################### ###################################
################################### ###################################
FROM ${GRPC_BASE_IMAGE} as grpc FROM ${GRPC_BASE_IMAGE} AS grpc
ARG MAKEFLAGS ARG MAKEFLAGS
ARG GRPC_VERSION=v1.58.0 ARG GRPC_VERSION=v1.58.0
@ -121,16 +121,15 @@ RUN apt-get update && \
RUN git clone --recurse-submodules --jobs 4 -b ${GRPC_VERSION} --depth 1 --shallow-submodules https://github.com/grpc/grpc RUN git clone --recurse-submodules --jobs 4 -b ${GRPC_VERSION} --depth 1 --shallow-submodules https://github.com/grpc/grpc
RUN cd grpc && \ WORKDIR /build/grpc/cmake/build
mkdir -p cmake/build && \
cd cmake/build && \ RUN cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF ../.. && \
cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF ../.. && \
make make
################################### ###################################
################################### ###################################
FROM requirements-${IMAGE_TYPE} as builder FROM requirements-${IMAGE_TYPE} AS builder
ARG GO_TAGS="stablediffusion tts" ARG GO_TAGS="stablediffusion tts"
ARG GRPC_BACKENDS ARG GRPC_BACKENDS
@ -168,9 +167,11 @@ RUN GRPC_BACKENDS=backend-assets/grpc/stablediffusion make build
COPY --from=grpc /build/grpc ./grpc/ COPY --from=grpc /build/grpc ./grpc/
RUN cd /build/grpc/cmake/build && make install WORKDIR /build/grpc/cmake/build
RUN make install
# Rebuild with defaults backends # Rebuild with defaults backends
WORKDIR /build
RUN make build RUN make build
RUN if [ ! -d "/build/sources/go-piper/piper-phonemize/pi/lib/" ]; then \ RUN if [ ! -d "/build/sources/go-piper/piper-phonemize/pi/lib/" ]; then \
@ -288,7 +289,7 @@ RUN mkdir -p /build/models
# Define the health check command # Define the health check command
HEALTHCHECK --interval=1m --timeout=10m --retries=10 \ HEALTHCHECK --interval=1m --timeout=10m --retries=10 \
CMD curl -f $HEALTHCHECK_ENDPOINT || exit 1 CMD curl -f ${HEALTHCHECK_ENDPOINT} || exit 1
VOLUME /build/models VOLUME /build/models
EXPOSE 8080 EXPOSE 8080

View File

@ -455,7 +455,6 @@ func DeleteAssistantFileEndpoint(cl *config.BackendConfigLoader, ml *model.Model
for i, assistant := range Assistants { for i, assistant := range Assistants {
if assistant.ID == assistantID { if assistant.ID == assistantID {
for j, fileId := range assistant.FileIDs { for j, fileId := range assistant.FileIDs {
if fileId == fileId {
Assistants[i].FileIDs = append(Assistants[i].FileIDs[:j], Assistants[i].FileIDs[j+1:]...) Assistants[i].FileIDs = append(Assistants[i].FileIDs[:j], Assistants[i].FileIDs[j+1:]...)
// Check if the file exists in the assistantFiles slice // Check if the file exists in the assistantFiles slice
@ -472,7 +471,6 @@ func DeleteAssistantFileEndpoint(cl *config.BackendConfigLoader, ml *model.Model
} }
} }
} }
}
log.Warn().Msgf("Unable to locate file_id: %s in assistants: %s. Continuing to delete assistant file.", fileId, assistantID) log.Warn().Msgf("Unable to locate file_id: %s in assistants: %s. Continuing to delete assistant file.", fileId, assistantID)
for i, assistantFile := range AssistantFiles { for i, assistantFile := range AssistantFiles {