-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
57 lines (37 loc) · 1.68 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
FROM quay.io/cdis/amazonlinux:python3.9-master as build-deps
USER root
ENV appname=gen3discoveryai
RUN pip3 install --no-cache-dir --upgrade poetry
RUN yum update -y && yum install -y --setopt install_weak_deps=0 \
kernel-devel libffi-devel libxml2-devel libxslt-devel postgresql-devel python3-devel \
git && yum clean all
WORKDIR /$appname
# copy ONLY poetry artifact, install the dependencies but not gen3discoveryai
# this will make sure that the dependencies are cached
COPY poetry.lock pyproject.toml /$appname/
COPY ./docs/openapi.yaml /$appname/docs/openapi.yaml
RUN poetry config virtualenvs.in-project true \
&& poetry install -vv --no-root --only main --no-interaction \
&& poetry show -v
# copy source code ONLY after installing dependencies
COPY . /$appname
# install gen3discoveryai
RUN poetry config virtualenvs.in-project true \
&& poetry install -vv --only main --no-interaction \
&& poetry show -v
#Creating the runtime image
FROM quay.io/cdis/amazonlinux:python3.9-master
ENV appname=gen3discoveryai
USER root
EXPOSE 80
RUN pip3 install --no-cache-dir --upgrade poetry
RUN yum update -y && yum install -y --setopt install_weak_deps=0 \
postgresql-devel shadow-utils\
bash && yum clean all
RUN useradd -ms /bin/bash appuser
COPY --from=build-deps --chown=appuser:appuser /$appname /$appname
WORKDIR /$appname
USER appuser
# Cache the necessary tiktoken encoding file
RUN poetry run python -c "from langchain.text_splitter import TokenTextSplitter; TokenTextSplitter.from_tiktoken_encoder(chunk_size=100, chunk_overlap=0)"
CMD ["poetry", "run", "gunicorn", "gen3discoveryai.main:app", "-k", "uvicorn.workers.UvicornWorker", "-c", "gunicorn.conf.py"]