-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
37 lines (26 loc) · 1.03 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
FROM python:3.10-slim-buster
# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1
# Install poetry and export PATH
RUN pip install poetry==1.3.2
ENV PATH="$HOME/.local/bin:$PATH"
# Create app directory
WORKDIR /app
# Disable virtualenv creation
RUN poetry config virtualenvs.create false
# Set max workers to 10 (default: number of cores + 4) to prevent cause max connection pool errors
RUN poetry config installer.max-workers 10
# Install dependencies
COPY poetry.lock pyproject.toml ./
RUN poetry install --no-dev --no-interaction --no-ansi --no-root --no-cache -vv
# Copy app source
COPY ./src .
# Copy .env file
COPY .env* .
# Load model from Hugging Face
RUN python3 utils/loadmodel.py
# Purge cache as it will make the final image large
RUN pip cache purge && rm -rf ~/.cache/pypoetry/artifacts && rm -rf ~/.cache/pypoetry/cache && rm -rf ~/.cache/huggingface
CMD [ "python3", "-m" , "flask", "--app=app", "run", "--host=0.0.0.0"]