passthrough / Dockerfile
mikmc's picture
Update Dockerfile
b85de66 verified
Raw History Blame Contribute Delete
1.12 kB
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"]