Dockerfile 887 B

123456789101112131415161718192021222324
  1. FROM tiangolo/uvicorn-gunicorn-fastapi:python3.10
  2. WORKDIR /app/
  3. RUN sed -i s@/deb.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list.d/debian.sources \
  4. && sed -i s@/security.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list.d/debian.sources
  5. RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/opt/poetry python && \
  6. cd /usr/local/bin && \
  7. ln -s /opt/poetry/bin/poetry && \
  8. poetry config virtualenvs.create false
  9. COPY ./pyproject.toml ./poetry.lock* /app/
  10. ARG INSTALL_DEV=false
  11. RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --only main ; fi"
  12. ENV PYTHONPATH=/app
  13. ENV PYTHONDONTWRITEBYTECODE=1
  14. ENV PYTHONUNBUFFERED=1
  15. # COPY ./.env /
  16. # USER appuser
  17. VOLUME [ "/app" ]
  18. EXPOSE 8080
  19. CMD ["gunicorn", "-k", "uvicorn.workers.UvicornWorker", "-c", "gunicorn_conf.py", "main:app", "--reload"]