-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
84 lines (58 loc) · 2.52 KB
/
Dockerfile
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
FROM public.ecr.aws/lambda/python:3.8
ARG AWS_ACCESS_KEY_ID
ARG AWS_SECRET_ACCESS_KEY
ARG AWS_DEFAULT_REGION
ARG MODEL_DIR=./models
RUN mkdir $MODEL_DIR
RUN ls -all
# aws credentials configuration
ENV AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION
# Added the Transformers cache directory as models
ENV TRANSFORMERS_CACHE=$MODEL_DIR \
TRANSFORMERS_VERBOSITY=error
# ENV HF_HOME="/home/abhishek/app/hf_cache_home"
# install requirements
RUN yum install git -y && yum -y install gcc-c++
COPY requirements.txt .
RUN pip install -r requirements.txt --target "${LAMBDA_TASK_ROOT}"
COPY ./ ./
COPY lambda_handler.py ${LAMBDA_TASK_ROOT}
ENV PYTHONPATH "${PYTHONPATH}:./"
# WORKDIR ./
RUN ls -all
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
RUN pip install "dvc[s3]" # since s3 is the remote storage
RUN pip install awscli
RUN pip install boto3
RUN pip install --upgrade transformers
RUN mkdir bert_uncased_L-2_H-128_A-2
RUN curl -L https://huggingface.co/google/bert_uncased_L-2_H-128_A-2/resolve/main/pytorch_model.bin -o ./bert_uncased_L-2_H-128_A-2/pytorch_model.bin
RUN curl https://huggingface.co/google/bert_uncased_L-2_H-128_A-2/resolve/main/config.json -o ./bert_uncased_L-2_H-128_A-2/config.json
RUN curl https://huggingface.co/google/bert_uncased_L-2_H-128_A-2/resolve/main/tokenizer.json -o ./bert_uncased_L-2_H-128_A-2/tokenizer.json
RUN curl https://huggingface.co/google/bert_uncased_L-2_H-128_A-2/resolve/main/tokenizer_config.json -o ./bert_uncased_L-2_H-128_A-2/tokenizer_config.json
RUN ls -all
RUN pwd
RUN whoami
# initialise dvc
RUN dvc init --no-scm -f
# this will set the ~/.aws/config req
RUN aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
RUN aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
RUN aws configure set default.region $AWS_DEFAULT_REGION
# check if ~/.aws/config set
RUN aws configure list
# # configuring remote server in dvc
RUN dvc remote add -d model-store s3://model-dvc-storage/trained_model/
# RUN aws s3 ls s3://model-dvc-storage/trained_model/
RUN dvc remote modify model-store access_key_id $AWS_ACCESS_KEY_ID
RUN dvc remote modify model-store secret_access_key $AWS_SECRET_ACCESS_KEY
RUN dvc remote modify model-store region $AWS_DEFAULT_REGION
# pulling the trained model
RUN dvc pull trained_model.dvc
# # running the application
RUN python lambda_handler.py
RUN chmod -R 0755 $MODEL_DIR
CMD [ "lambda_handler.lambda_handler"]