Skip to content

Commit

Permalink
CI Security Fix : expose action cache url and runtime as secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
glegendre01 committed Jan 29, 2025
1 parent 2ace258 commit 5ad1cf2
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 21 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,13 @@ jobs:
platforms: 'linux/amd64'
build-args: |
SCCACHE_GHA_ENABLED=${{ matrix.sccache }}
ACTIONS_CACHE_URL=${{ env.ACTIONS_CACHE_URL }}
ACTIONS_RUNTIME_TOKEN=${{ env.ACTIONS_RUNTIME_TOKEN }}
CUDA_COMPUTE_CAP=${{ matrix.cudaComputeCap }}
GIT_SHA=${{ env.GITHUB_SHA }}
DOCKER_LABEL=sha-${{ env.GITHUB_SHA_SHORT }}
${{matrix.extraBuildArgs}}
secrets: |
actions_cache_url=${{ env.ACTIONS_CACHE_URL }}
actions_runtime_token=${{ env.ACTIONS_RUNTIME_TOKEN }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=s3,region=us-east-1,bucket=${{ vars.AWS_S3BUCKET_GITHUB_BUILDX_CACHE }},name=text-embeddings-inference-cache-${{matrix.name}},access_key_id=${{ steps.aws-creds.outputs.aws-access-key-id }},secret_access_key=${{ steps.aws-creds.outputs.aws-secret-access-key }},session_token=${{ steps.aws-creds.outputs.aws-session-token }},mode=max
Expand Down Expand Up @@ -168,12 +169,13 @@ jobs:
platforms: 'linux/amd64'
build-args: |
SCCACHE_GHA_ENABLED=${{ matrix.sccache }}
ACTIONS_CACHE_URL=${{ env.ACTIONS_CACHE_URL }}
ACTIONS_RUNTIME_TOKEN=${{ env.ACTIONS_RUNTIME_TOKEN }}
CUDA_COMPUTE_CAP=${{ matrix.cudaComputeCap }}
GIT_SHA=${{ env.GITHUB_SHA }}
DOCKER_LABEL=sha-${{ env.GITHUB_SHA_SHORT }}
${{matrix.extraBuildArgs}}
secrets: |
actions_cache_url=${{ env.ACTIONS_CACHE_URL }}
actions_runtime_token=${{ env.ACTIONS_RUNTIME_TOKEN }}
tags: ${{ steps.meta-grpc.outputs.tags }}
labels: ${{ steps.meta-grpc.outputs.labels }}
cache-from: type=s3,region=us-east-1,bucket=${{ vars.AWS_S3BUCKET_GITHUB_BUILDX_CACHE }},name=text-embeddings-inference-cache-${{matrix.name}},access_key_id=${{ steps.aws-creds.outputs.aws-access-key-id }},secret_access_key=${{ steps.aws-creds.outputs.aws-secret-access-key }},session_token=${{ steps.aws-creds.outputs.aws-session-token }},mode=max
10 changes: 6 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ ARG GIT_SHA
ARG DOCKER_LABEL

# sccache specific variables
ARG ACTIONS_CACHE_URL
ARG ACTIONS_RUNTIME_TOKEN
ARG SCCACHE_GHA_ENABLED

RUN wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
Expand Down Expand Up @@ -53,7 +51,9 @@ COPY Cargo.lock ./

FROM builder AS http-builder

RUN cargo build --release --bin text-embeddings-router -F ort -F candle -F mkl-dynamic -F http --no-default-features && sccache -s
RUN --mount=type=secret,id=actions_cache_url,env=ACTIONS_CACHE_URL \
--mount=type=secret,id=actions_runtime_token,env=ACTIONS_RUNTIME_TOKEN \
cargo build --release --bin text-embeddings-router -F ort -F candle -F mkl-dynamic -F http --no-default-features && sccache -s

FROM builder AS grpc-builder

Expand All @@ -65,7 +65,9 @@ RUN PROTOC_ZIP=protoc-21.12-linux-x86_64.zip && \

COPY proto proto

RUN cargo build --release --bin text-embeddings-router -F grpc -F ort -F candle -F mkl-dynamic --no-default-features && sccache -s
RUN --mount=type=secret,id=actions_cache_url,env=ACTIONS_CACHE_URL \
--mount=type=secret,id=actions_runtime_token,env=ACTIONS_RUNTIME_TOKEN \
cargo build --release --bin text-embeddings-router -F grpc -F ort -F candle -F mkl-dynamic --no-default-features && sccache -s

FROM debian:bookworm-slim AS base

Expand Down
10 changes: 6 additions & 4 deletions Dockerfile-cuda
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ ARG CARGO_BUILD_JOBS
ARG CARGO_BUILD_INCREMENTAL

# sccache specific variables
ARG ACTIONS_CACHE_URL
ARG ACTIONS_RUNTIME_TOKEN
ARG SCCACHE_GHA_ENABLED

WORKDIR /usr/src
Expand Down Expand Up @@ -77,7 +75,9 @@ COPY Cargo.lock ./

FROM builder AS http-builder

RUN if [ ${CUDA_COMPUTE_CAP} -ge 75 -a ${CUDA_COMPUTE_CAP} -lt 80 ]; \
RUN --mount=type=secret,id=actions_cache_url,env=ACTIONS_CACHE_URL \
--mount=type=secret,id=actions_runtime_token,env=ACTIONS_RUNTIME_TOKEN \
if [ ${CUDA_COMPUTE_CAP} -ge 75 -a ${CUDA_COMPUTE_CAP} -lt 80 ]; \
then \
cargo build --release --bin text-embeddings-router -F candle-cuda-turing -F static-linking -F http --no-default-features && sccache -s; \
else \
Expand All @@ -98,7 +98,9 @@ RUN PROTOC_ZIP=protoc-21.12-linux-x86_64.zip && \

COPY proto proto

RUN if [ ${CUDA_COMPUTE_CAP} -ge 75 -a ${CUDA_COMPUTE_CAP} -lt 80 ]; \
RUN --mount=type=secret,id=actions_cache_url,env=ACTIONS_CACHE_URL \
--mount=type=secret,id=actions_runtime_token,env=ACTIONS_RUNTIME_TOKEN \
if [ ${CUDA_COMPUTE_CAP} -ge 75 -a ${CUDA_COMPUTE_CAP} -lt 80 ]; \
then \
cargo build --release --bin text-embeddings-router -F candle-cuda-turing -F static-linking -F grpc --no-default-features && sccache -s; \
else \
Expand Down
14 changes: 9 additions & 5 deletions Dockerfile-cuda-all
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ ARG DOCKER_LABEL
ARG VERTEX="false"

# sccache specific variables
ARG ACTIONS_CACHE_URL
ARG ACTIONS_RUNTIME_TOKEN
ARG SCCACHE_GHA_ENABLED

# Limit parallelism
Expand Down Expand Up @@ -83,7 +81,9 @@ COPY router router
COPY Cargo.toml ./
COPY Cargo.lock ./

RUN if [ $VERTEX = "true" ]; \
RUN --mount=type=secret,id=actions_cache_url,env=ACTIONS_CACHE_URL \
--mount=type=secret,id=actions_runtime_token,env=ACTIONS_RUNTIME_TOKEN \
if [ $VERTEX = "true" ]; \
then \
CUDA_COMPUTE_CAP=75 cargo build --release --bin text-embeddings-router -F candle-cuda-turing -F google && sccache -s; \
else \
Expand All @@ -92,7 +92,9 @@ RUN if [ $VERTEX = "true" ]; \

RUN mv /usr/src/target/release/text-embeddings-router /usr/src/target/release/text-embeddings-router-75

RUN if [ $VERTEX = "true" ]; \
RUN --mount=type=secret,id=actions_cache_url,env=ACTIONS_CACHE_URL \
--mount=type=secret,id=actions_runtime_token,env=ACTIONS_RUNTIME_TOKEN \
if [ $VERTEX = "true" ]; \
then \
CUDA_COMPUTE_CAP=80 cargo build --release --bin text-embeddings-router -F candle-cuda -F google && sccache -s; \
else \
Expand All @@ -101,7 +103,9 @@ RUN if [ $VERTEX = "true" ]; \

RUN mv /usr/src/target/release/text-embeddings-router /usr/src/target/release/text-embeddings-router-80

RUN if [ $VERTEX = "true" ]; \
RUN --mount=type=secret,id=actions_cache_url,env=ACTIONS_CACHE_URL \
--mount=type=secret,id=actions_runtime_token,env=ACTIONS_RUNTIME_TOKEN \
if [ $VERTEX = "true" ]; \
then \
CUDA_COMPUTE_CAP=90 cargo build --release --bin text-embeddings-router -F candle-cuda -F google && sccache -s; \
else \
Expand Down
10 changes: 6 additions & 4 deletions Dockerfile-intel
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ ARG GIT_SHA
ARG DOCKER_LABEL

# sccache specific variables
ARG ACTIONS_CACHE_URL
ARG ACTIONS_RUNTIME_TOKEN
ARG SCCACHE_GHA_ENABLED

COPY --from=planner /usr/src/recipe.json recipe.json
Expand All @@ -46,13 +44,17 @@ RUN PROTOC_ZIP=protoc-21.12-linux-x86_64.zip && \

FROM builder as http-builder

RUN cargo build --release --bin text-embeddings-router -F python -F http --no-default-features && sccache -s
RUN --mount=type=secret,id=actions_cache_url,env=ACTIONS_CACHE_URL \
--mount=type=secret,id=actions_runtime_token,env=ACTIONS_RUNTIME_TOKEN \
cargo build --release --bin text-embeddings-router -F python -F http --no-default-features && sccache -s

FROM builder as grpc-builder

COPY proto proto

RUN cargo build --release --bin text-embeddings-router -F grpc -F python --no-default-features && sccache -s
RUN --mount=type=secret,id=actions_cache_url,env=ACTIONS_CACHE_URL \
--mount=type=secret,id=actions_runtime_token,env=ACTIONS_RUNTIME_TOKEN \
cargo build --release --bin text-embeddings-router -F grpc -F python --no-default-features && sccache -s

FROM intel/intel-optimized-pytorch:2.4.0-pip-base AS cpu
ENV HUGGINGFACE_HUB_CACHE=/data \
Expand Down

0 comments on commit 5ad1cf2

Please sign in to comment.