You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.8 KiB

  1. ARG PYTHON_VERSION="3.8.13-slim-bullseye"
  2. FROM python:${PYTHON_VERSION} AS backend-builder
  3. # hadolint ignore=DL3008
  4. RUN apt-get update \
  5. && apt-get install -y --no-install-recommends \
  6. netcat=1.* \
  7. libpq-dev=13.* \
  8. unixodbc-dev=2.* \
  9. g++=4:* \
  10. libssl-dev=1.* \
  11. curl \
  12. && apt-get clean \
  13. && rm -rf /var/lib/apt/lists/*
  14. WORKDIR /tmp
  15. COPY backend/pyproject.toml backend/poetry.lock /tmp/
  16. SHELL ["/bin/bash", "-o", "pipefail", "-c"]
  17. RUN pip install -U --no-cache-dir pip==22.2.2 \
  18. && curl -sSL https://install.python-poetry.org | python - \
  19. && export PATH="/root/.local/bin:$PATH" \
  20. && poetry export --without-hashes -o /requirements.txt \
  21. && echo "psycopg2-binary==2.8.6" >> /requirements.txt \
  22. && pip install --no-cache-dir -r /requirements.txt
  23. FROM python:${PYTHON_VERSION} AS runtime
  24. WORKDIR /backend
  25. RUN apt-get update \
  26. && apt-get install -y --no-install-recommends \
  27. libpq-dev=13.* \
  28. unixodbc-dev=2.* \
  29. libssl-dev=1.* \
  30. && apt-get clean \
  31. && rm -rf /var/lib/apt/lists/*
  32. RUN groupadd -g 61000 doccano \
  33. && useradd -g 61000 -l -M -s /bin/false -u 61000 doccano
  34. COPY --from=backend-builder /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages
  35. COPY --from=backend-builder /usr/local/bin/celery /usr/local/bin/celery
  36. COPY --from=backend-builder /usr/local/bin/gunicorn /usr/local/bin/gunicorn
  37. COPY --chown=doccano:doccano tools/ /opt/bin/
  38. COPY --chown=doccano:doccano backend/ /backend/
  39. RUN mkdir -p /backend/staticfiles \
  40. && mkdir -p /backend/client/dist/static \
  41. && mkdir -p /backend/media \
  42. && mkdir -p /backend/filepond-temp-uploads \
  43. && chown -R doccano:doccano /backend/
  44. ENV PYTHONDONTWRITEBYTECODE 1
  45. ENV PYTHONUNBUFFERED 1
  46. USER doccano:doccano
  47. VOLUME /backend/staticfiles
  48. ENTRYPOINT [ "/opt/bin/prod-django.sh" ]