celariumv1.2 / Dockerfile
user9200's picture
Update Dockerfile
bd73366 verified
Raw
History Blame Contribute Delete
866 Bytes
FROM python:3.10-slim
# minimal system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential git && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# copy requirements and constraints first to leverage cache
COPY requirements.txt /app/requirements.txt
COPY constraints.txt /app/constraints.txt
# upgrade pip and install torch CPU wheel first, then remaining packages
RUN pip install --upgrade pip setuptools wheel \
&& pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu torch==2.0.1 \
&& pip install --no-cache-dir --prefer-binary -r /app/requirements.txt -c /app/constraints.txt
# copy the rest of the code
COPY . /app
# runtime environment variable for port
ENV PORT=8000
# expose port
EXPOSE 8000
# run uvicorn
CMD ["sh", "-c", "uvicorn app:app --host 0.0.0.0 --port ${PORT} --workers 1"]