-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile.ttc
More file actions
49 lines (35 loc) · 2.65 KB
/
Dockerfile.ttc
File metadata and controls
49 lines (35 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
FROM public.ecr.aws/lambda/python:3.12
LABEL org.opencontainers.image.source=https://github.com/CDCgov/dibbs-text-to-code
LABEL org.opencontainers.image.licenses=Apache-2.0
# Install build tools for C++ extensions
RUN microdnf install -y gcc-c++ make && microdnf clean all
# Heavy, rarely-changing layers first so they stay cached across source changes.
# Install CPU-only PyTorch before any workspace package — a transitive pin
# could otherwise pull the full CUDA wheel before our override lands.
RUN pip install --no-cache-dir torch==2.9.1 --index-url https://download.pytorch.org/whl/cpu
RUN pip install --no-cache-dir huggingface_hub
# Download retriever at build time (private repo, needs token)
RUN --mount=type=secret,id=huggingface_token,env=HF_TOKEN \
python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='NCHS/ttc-retriever-mvp', local_dir='/opt/retriever_model', ignore_patterns=['*.git*', '*.md', 'onnx/*', 'openvino/*', 'pytorch_model.bin', 'tf_model.h5', 'flax_model.msgpack', 'model.onnx'])"
# Download reranker at build time (private repo, needs token)
RUN --mount=type=secret,id=huggingface_token,env=HF_TOKEN \
python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='NCHS/ttc-reranker-mvp', local_dir='/opt/reranker_model', ignore_patterns=['*.git*', '*.md', 'onnx/*', 'openvino/*', 'pytorch_model.bin', 'tf_model.h5', 'flax_model.msgpack', 'model.onnx'])" \
&& rm -rf /root/.cache/huggingface
# Workspace packages (change frequently) come after the heavy layers.
COPY ./packages/shared-models ${LAMBDA_TASK_ROOT}/shared-models
RUN pip install --no-cache-dir "${LAMBDA_TASK_ROOT}/shared-models"
COPY ./packages/utils ${LAMBDA_TASK_ROOT}/utils
RUN pip install --no-cache-dir "${LAMBDA_TASK_ROOT}/utils"
COPY ./packages/lambda-handler ${LAMBDA_TASK_ROOT}/lambda-handler
RUN pip install --no-cache-dir "${LAMBDA_TASK_ROOT}/lambda-handler"
COPY ./packages/text-to-code ${LAMBDA_TASK_ROOT}/text-to-code
RUN pip install --no-cache-dir "${LAMBDA_TASK_ROOT}/text-to-code"
COPY ./packages/text-to-code-lambda ${LAMBDA_TASK_ROOT}/text-to-code-lambda
RUN pip install --no-cache-dir "${LAMBDA_TASK_ROOT}/text-to-code-lambda"
# Remove build tools no longer needed at runtime
RUN rpm -e --nodeps gcc-c++ gcc cpp make && microdnf clean all && rm -rf /var/cache/*
# Clean up package source copies
RUN rm -rf ${LAMBDA_TASK_ROOT}/shared-models ${LAMBDA_TASK_ROOT}/utils ${LAMBDA_TASK_ROOT}/lambda-handler ${LAMBDA_TASK_ROOT}/text-to-code ${LAMBDA_TASK_ROOT}/text-to-code-lambda
ENV RETRIEVER_MODEL_PATH="/opt/retriever_model"
ENV RERANKER_MODEL_PATH="/opt/reranker_model"
CMD ["text_to_code_lambda.lambda_function.handler"]