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.

82 lines
2.4 KiB

2 years ago
2 years ago
  1. ARG PYTHON_VERSION="3.8.12-slim-buster"
  2. ARG NODE_VERSION="16.14-buster-slim"
  3. FROM node:${NODE_VERSION} AS frontend-builder
  4. COPY frontend/ /frontend/
  5. WORKDIR /frontend
  6. ENV PUBLIC_PATH="/static/_nuxt/"
  7. # hadolint ignore=DL3008
  8. RUN apt-get update \
  9. && apt-get install -y --no-install-recommends git python3 make g++ ca-certificates \
  10. && git config --global url."https://github.com/".insteadOf git://github.com/ \
  11. && yarn install \
  12. && yarn build \
  13. && apt-get clean \
  14. && rm -rf /var/lib/apt/lists/*
  15. FROM python:${PYTHON_VERSION} AS backend-builder
  16. # hadolint ignore=DL3008
  17. RUN apt-get update \
  18. && apt-get install -y --no-install-recommends \
  19. netcat=1.* \
  20. libpq-dev=11.* \
  21. unixodbc-dev=2.* \
  22. g++=4:* \
  23. libssl-dev=1.* \
  24. curl \
  25. && apt-get clean \
  26. && rm -rf /var/lib/apt/lists/*
  27. WORKDIR /tmp
  28. COPY backend/pyproject.toml backend/poetry.lock /tmp/
  29. SHELL ["/bin/bash", "-o", "pipefail", "-c"]
  30. RUN pip install --no-cache-dir pip==22.0.4 \
  31. && curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - \
  32. && PATH="${PATH}:$HOME/.poetry/bin" \
  33. && poetry export --without-hashes -o /requirements.txt \
  34. && echo "psycopg2-binary==2.8.6" >> /requirements.txt \
  35. && echo "django-heroku==0.3.1" >> /requirements.txt \
  36. && pip install --no-cache-dir -r /requirements.txt
  37. FROM python:${PYTHON_VERSION} AS runtime
  38. RUN apt-get update \
  39. && apt-get install -y --no-install-recommends \
  40. libpq-dev=11.* \
  41. unixodbc-dev=2.* \
  42. libssl-dev=1.* \
  43. && apt-get clean \
  44. && rm -rf /var/lib/apt/lists/*
  45. RUN useradd -ms /bin/sh doccano
  46. RUN mkdir /data \
  47. && chown doccano:doccano /data
  48. COPY --from=backend-builder /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages
  49. COPY --from=backend-builder /usr/local/bin/celery /usr/local/bin/celery
  50. COPY --from=backend-builder /usr/local/bin/gunicorn /usr/local/bin/gunicorn
  51. COPY --chown=doccano:doccano . /doccano
  52. WORKDIR /doccano/backend
  53. COPY --from=frontend-builder /frontend/dist /doccano/backend/client/dist
  54. RUN python manage.py collectstatic --noinput \
  55. && chown -R doccano:doccano .
  56. VOLUME /data
  57. ENV DATABASE_URL="sqlite:////data/doccano.db"
  58. ENV DEBUG="False"
  59. ENV STANDALONE="True"
  60. ENV SECRET_KEY="change-me-in-production"
  61. ENV PORT="8000"
  62. ENV WORKERS="2"
  63. ENV CELERY_WORKERS="2"
  64. ENV GOOGLE_TRACKING_ID=""
  65. ENV DJANGO_SETTINGS_MODULE="config.settings.production"
  66. USER doccano
  67. EXPOSE ${PORT}
  68. CMD ["/doccano/tools/run.sh"]