Spaces:
Runtime error
Runtime error
Commit
·
63f1d95
1
Parent(s):
1cc5ca2
added dockerfile
Browse files- Dockerfile +45 -0
Dockerfile
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# NOTE: This is a sample dockerfile for creating docker images for deploying
|
| 2 |
+
# a haystack pipeline. Follow the comments and make suitable changes for your use-case.
|
| 3 |
+
#
|
| 4 |
+
# Use-case showcased here:
|
| 5 |
+
# Dockerfile for a <blah> pipeline
|
| 6 |
+
#
|
| 7 |
+
#
|
| 8 |
+
# We also show how to cache HuggingFace models; both public and private. More details in the comments.
|
| 9 |
+
# CAUTION: Do not use `huggingface-cli login` inside the docker as it store the access token locally
|
| 10 |
+
# Here we prefer passing access token as an `ARG` because,
|
| 11 |
+
# we only need to use access token to cache required model.
|
| 12 |
+
# Also, Do not create an ENV variable containing access token,
|
| 13 |
+
# as ENV variable remains active inside docker for its entire lifecycle.
|
| 14 |
+
# To know futher: https://huggingface.co/docs/hub/security-tokens#best-practices
|
| 15 |
+
|
| 16 |
+
# Choose appropriate Haystack base image (i.e. v1.13.2)
|
| 17 |
+
ARG HAYSTACK_BASE_IMAGE=deepset/haystack:cpu-v1.13.2
|
| 18 |
+
FROM $HAYSTACK_BASE_IMAGE
|
| 19 |
+
|
| 20 |
+
#ARG hf_model_names="['deepset/minilm-uncased-squad2']"
|
| 21 |
+
# `hf_model_names` should be a list of string containing model names from HuggingFace hub
|
| 22 |
+
# i.e., "['hf/model1']" or "['hf/model1', 'hf/model2', 'hf/model3']"
|
| 23 |
+
|
| 24 |
+
#ARG hf_token=''
|
| 25 |
+
|
| 26 |
+
# To cache HuggingFace public models
|
| 27 |
+
#RUN python3 -c "from haystack.utils.docker import cache_models;cache_models($hf_model_names)"
|
| 28 |
+
|
| 29 |
+
# To cache HuggingFace private models
|
| 30 |
+
#RUN python3 -c "from haystack.utils.docker import cache_models;cache_models($hf_model_names, $hf_token)"
|
| 31 |
+
|
| 32 |
+
# To copy pipeline yml into the docker
|
| 33 |
+
ARG local_pipeline_path=<blah>.yml
|
| 34 |
+
ARG container_pipeline_path=/opt/haystack_pipelines/reader_retriever.yml
|
| 35 |
+
COPY $local_pipeline_path $container_pipeline_path
|
| 36 |
+
|
| 37 |
+
# Exporting Pipeline path as an env variable
|
| 38 |
+
# Haystack reads this env variable to load the appropriate pipeline
|
| 39 |
+
ENV PIPELINE_YAML_PATH=$container_pipeline_path
|
| 40 |
+
|
| 41 |
+
RUN chmod 700 /opt/file-upload
|
| 42 |
+
# cmd for starting Haystack API server
|
| 43 |
+
CMD ["gunicorn", "rest_api.application:app", "-b", "0.0.0.0", "-k", "uvicorn.workers.UvicornWorker", "--workers", "1", "--timeout", "180"]
|
| 44 |
+
|
| 45 |
+
|