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