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.

83 lines
2.2 KiB

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