Spaces:
Paused
Paused
File size: 1,117 Bytes
355ea0f b85de66 | 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 | FROM python:3.12-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE="1"
ENV PYTHONUNBUFFERED="1"
ENV PORT="3000"
# Set work directory
WORKDIR /h_y
# Create a non-root user
RUN useradd -m h_y
RUN chown -R h_y:h_y /h_y
# Set up the PATH to include the user's local bin
ENV PATH="/home/h_y/.local/bin:$PATH"
# Switch to non-root user
USER h_y
# Install Poetry
RUN pip install --user --no-cache-dir poetry
# Copy only requirements to cache them in docker layer
COPY --chown=h_y:h_y pyproject.toml poetry.lock* /h_y/
# Project initialization:
RUN poetry config virtualenvs.in-project true \
&& poetry install --no-interaction --no-ansi --no-root --only main
# Copy project files
COPY --chown=h_y:h_y . /h_y
# Expose the port the app runs on
EXPOSE 3000
# Activate virtual environment and run the application with Gunicorn
CMD ["poetry", "run", "gunicorn", "h_y.main:app", "-w", "4", "-k", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:3000", "--timeout", "120", "--max-requests", "500", "--max-requests-jitter", "200", "--access-logfile", "-", "--error-logfile", "-", "--log-level", "info"]
|