From ddfecadb077c630b4c6e8d81adc9ee7fb9e3ef2d Mon Sep 17 00:00:00 2001 From: Justin Law Date: Thu, 8 Aug 2024 12:18:07 -0400 Subject: [PATCH] dockerfile fixes --- .github/workflows/docker-lint.yaml | 2 +- .hadolint.yaml | 8 ++++++++ .pre-commit-config.yaml | 2 +- Dockerfile.migrations | 11 ++++++----- packages/llama-cpp-python/Dockerfile | 2 +- packages/repeater/Dockerfile | 2 +- packages/text-embeddings/Dockerfile | 2 +- packages/vllm/Dockerfile | 2 +- packages/whisper/Dockerfile | 2 +- src/leapfrogai_sdk/Dockerfile | 7 ++++--- src/leapfrogai_ui/Dockerfile | 20 ++++++++++++++------ 11 files changed, 39 insertions(+), 21 deletions(-) create mode 100644 .hadolint.yaml diff --git a/.github/workflows/docker-lint.yaml b/.github/workflows/docker-lint.yaml index 3744e27b9..37a778a42 100644 --- a/.github/workflows/docker-lint.yaml +++ b/.github/workflows/docker-lint.yaml @@ -37,5 +37,5 @@ jobs: - uses: hadolint/hadolint-action@54c9adbab1582c2ef04b2016b760714a4bfde3cf # v3.1.0 with: dockerfile: "*Dockerfile*" - failure-threshold: error recursive: true + config: .hadolint.yaml diff --git a/.hadolint.yaml b/.hadolint.yaml new file mode 100644 index 000000000..0501bfd88 --- /dev/null +++ b/.hadolint.yaml @@ -0,0 +1,8 @@ +failure-threshold: error +# ignore: use of latest, --no-cache-dir, shell usage warning, apt-get list, --no-install-recommends +ignored: + - "DL3007" + - "DL3042" + - "DL4006" + - "DL3009" + - "DL3015" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3e2d79a64..2386287bf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -63,7 +63,7 @@ repos: hooks: - id: hadolint-docker name: Dockerfile Lint - args: ["--failure-threshold", "error"] + args: ["--config", ".hadolint.yaml"] - repo: local hooks: diff --git a/Dockerfile.migrations b/Dockerfile.migrations index c691ef54d..27bd326ef 100644 --- a/Dockerfile.migrations +++ b/Dockerfile.migrations @@ -1,13 +1,14 @@ FROM cgr.dev/chainguard/bash:latest -ARG TARGETPLATFORM -ARG version="1.169.8" -ARG MIGRATIONS_DIR + +ARG TARGETPLATFORM \ + version="1.169.8" \ + MIGRATIONS_DIR RUN test -n "$MIGRATIONS_DIR" || (echo "MIGRATIONS_PATH is required" && false) # Download the supabase cli -RUN mkdir -p /usr/local/bin -RUN ARCH=$(echo $TARGETPLATFORM | cut -d '/' -f2) \ +RUN mkdir -p /usr/local/bin \ + ARCH=$(echo $TARGETPLATFORM | cut -d "/" -f2) \ && curl -LO https://github.com/supabase/cli/releases/download/v${version}/supabase_linux_${ARCH}.tar.gz \ && tar -xzf supabase_linux_${ARCH}.tar.gz -C /usr/local/bin/ \ && rm supabase_linux_${ARCH}.tar.gz diff --git a/packages/llama-cpp-python/Dockerfile b/packages/llama-cpp-python/Dockerfile index b7041bed9..f4bd96320 100644 --- a/packages/llama-cpp-python/Dockerfile +++ b/packages/llama-cpp-python/Dockerfile @@ -33,6 +33,6 @@ COPY --from=builder /leapfrogai/.venv/ /leapfrogai/.venv/ COPY packages/llama-cpp-python/main.py . COPY packages/llama-cpp-python/config.yaml . -EXPOSE 50051:50051 +EXPOSE 50051 ENTRYPOINT ["python", "-m", "leapfrogai_sdk.cli", "--app-dir=.", "main:Model"] diff --git a/packages/repeater/Dockerfile b/packages/repeater/Dockerfile index 4d58f46a6..a55a9e261 100644 --- a/packages/repeater/Dockerfile +++ b/packages/repeater/Dockerfile @@ -30,7 +30,7 @@ COPY --from=builder /leapfrogai/.venv/ /leapfrogai/.venv/ COPY packages/repeater/repeater.py . # Publish port -EXPOSE 50051:50051 +EXPOSE 50051 # Run the repeater model ENTRYPOINT ["python", "-u", "repeater.py"] diff --git a/packages/text-embeddings/Dockerfile b/packages/text-embeddings/Dockerfile index 9af7c5537..53089450f 100644 --- a/packages/text-embeddings/Dockerfile +++ b/packages/text-embeddings/Dockerfile @@ -32,6 +32,6 @@ COPY --from=builder /leapfrogai/.venv/ /leapfrogai/.venv/ COPY packages/text-embeddings/main.py . -EXPOSE 50051:50051 +EXPOSE 50051 ENTRYPOINT ["python", "-u", "main.py"] diff --git a/packages/vllm/Dockerfile b/packages/vllm/Dockerfile index 859582c0e..16503c65b 100755 --- a/packages/vllm/Dockerfile +++ b/packages/vllm/Dockerfile @@ -121,6 +121,6 @@ ENV LAI_PROMPT_FORMAT_CHAT_USER=${PROMPT_FORMAT_CHAT_USER} ENV LAI_PROMPT_FORMAT_DEFAULTS_TOP_P=${PROMPT_FORMAT_DEFAULTS_TOP_P} ENV LAI_PROMPT_FORMAT_DEFAULTS_TOP_K=${PROMPT_FORMAT_DEFAULTS_TOP_K} -EXPOSE 50051:50051 +EXPOSE 50051 ENTRYPOINT ["python", "-m", "leapfrogai_sdk.cli", "--app-dir=packages/vllm/src/", "main:Model"] diff --git a/packages/whisper/Dockerfile b/packages/whisper/Dockerfile index e7568da48..1e0260a34 100644 --- a/packages/whisper/Dockerfile +++ b/packages/whisper/Dockerfile @@ -42,6 +42,6 @@ ENV LD_LIBRARY_PATH \ COPY packages/whisper/main.py . -EXPOSE 50051:50051 +EXPOSE 50051 ENTRYPOINT ["python", "-u", "main.py"] diff --git a/src/leapfrogai_sdk/Dockerfile b/src/leapfrogai_sdk/Dockerfile index 5fa4b6346..5d54543ab 100644 --- a/src/leapfrogai_sdk/Dockerfile +++ b/src/leapfrogai_sdk/Dockerfile @@ -1,12 +1,13 @@ FROM ghcr.io/defenseunicorns/leapfrogai/python:3.11-dev AS builder ARG SDK_DEST=src/leapfrogai_sdk/build -USER root + WORKDIR /leapfrogai COPY ./src/leapfrogai_sdk /leapfrogai/src/leapfrogai_sdk RUN python -m venv .venv ENV PATH="/leapfrogai/.venv/bin:$PATH" -RUN rm -f ${SDK_DEST}/*.whl -RUN python -m pip wheel src/leapfrogai_sdk -w ${SDK_DEST} + +RUN rm -f ${SDK_DEST}/*.whl \ + python -m pip wheel src/leapfrogai_sdk -w ${SDK_DEST} diff --git a/src/leapfrogai_ui/Dockerfile b/src/leapfrogai_ui/Dockerfile index ec1cbf206..e1f99abd7 100644 --- a/src/leapfrogai_ui/Dockerfile +++ b/src/leapfrogai_ui/Dockerfile @@ -1,12 +1,18 @@ FROM node:18-alpine AS builder + WORKDIR /app + COPY package.json ./ COPY package-lock.json ./ + RUN npm ci + COPY . . + ENV NODE_ENV=production -RUN npm run build -RUN npm prune + +RUN npm run build && \ + npm prune FROM cgr.dev/chainguard/node:latest @@ -15,9 +21,11 @@ COPY --chown=node:node --from=builder /app/build build/ COPY --chown=node:node --from=builder /app/node_modules node_modules/ COPY --chown=node:node package.json . EXPOSE 3000 -ENV NODE_ENV=production + # Disable request size limit -ENV BODY_SIZE_LIMIT=Infinity -ENV PROTOCOL_HEADER=x-forwarded-proto -ENV HOST_HEADER=x-forwarded-host +ENV BODY_SIZE_LIMIT=Infinity \ + NODE_ENV=production \ + PROTOCOL_HEADER=x-forwarded-proto \ + HOST_HEADER=x-forwarded-host + CMD ["build"]