Dockerfile 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. # Copyright 2016-TODAY LasLabs Inc.
  2. # License MIT (https://opensource.org/licenses/MIT).
  3. # Some of this taken from https://github.com/Tecnativa/odoo/blob/docker/Dockerfile
  4. # @TODO: Submit upstream PR with changes & move out the duplicate logic.
  5. FROM python:2-alpine
  6. MAINTAINER "LasLabs Inc." <support@laslabs.com>
  7. ARG ODOO_VERSION="9.0"
  8. ARG ODOO_REPO="odoo/odoo"
  9. ARG ODOO_CONFIG_FILE="odoo.conf"
  10. ARG ODOO_CONFIG_DIR="/etc/odoo"
  11. ARG WKHTMLTOX_VERSION="0.12"
  12. ARG WKHTMLTOX_SUBVERSION="4"
  13. ENV ODOO_LOG="/var/log/odoo.log"
  14. ENV ODOO_CONFIG="${ODOO_CONFIG_DIR}/${ODOO_CONFIG_FILE}"
  15. ENV WKHTMLTOX_RELEASE="${WKHTMLTOX_VERSION}.${WKHTMLTOX_SUBVERSION}"
  16. ENV WKHTMLTOX_URI="http://download.gna.org/wkhtmltopdf/${WKHTMLTOX_VERSION}/${WKHTMLTOX_RELEASE}/wkhtmltox-${WKHTMLTOX_RELEASE}_linux-generic-amd64.tar.xz"
  17. ENV ODOO_URI="https://github.com/${ODOO_REPO}/archive/${ODOO_VERSION}.tar.gz"
  18. # https://github.com/OCA/maintainer-quality-tools/pull/404
  19. ENV MQT_URI="https://github.com/LasLabs/maintainer-quality-tools/archive/bugfix/script-shebang.tar.gz"
  20. # Set this as an env var instead of arg so its avail to entrypoint
  21. ENV ODOO_VERSION=$ODOO_VERSION
  22. # Other requirements and recommendations to run Odoo
  23. # See https://github.com/$ODOO_SOURCE/blob/$ODOO_VERSION/debian/control
  24. RUN apk add --no-cache \
  25. git \
  26. ghostscript \
  27. icu \
  28. libev \
  29. nodejs \
  30. openssl \
  31. postgresql-libs \
  32. poppler-utils \
  33. ruby \
  34. su-exec
  35. # Special case for wkhtmltox
  36. # HACK https://github.com/wkhtmltopdf/wkhtmltopdf/issues/3265
  37. # Idea from https://hub.docker.com/r/loicmahieu/alpine-wkhtmltopdf/
  38. # Use prepackaged wkhtmltopdf and wrap it with a dummy X server
  39. RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing wkhtmltopdf
  40. RUN apk add --no-cache xvfb ttf-dejavu ttf-freefont fontconfig dbus
  41. COPY bin/wkhtmltox.sh /usr/local/bin/wkhtmltoimage
  42. RUN ln /usr/local/bin/wkhtmltoimage /usr/local/bin/wkhtmltopdf
  43. # Requirements to build Odoo dependencies
  44. RUN apk add --no-cache --virtual .build-deps \
  45. curl \
  46. # Common to all Python packages
  47. build-base \
  48. tar \
  49. python-dev \
  50. # lxml
  51. libxml2-dev \
  52. libxslt-dev \
  53. # Pillow
  54. freetype-dev \
  55. jpeg-dev \
  56. lcms2-dev \
  57. openjpeg-dev \
  58. tcl-dev \
  59. tiff-dev \
  60. tk-dev \
  61. zlib-dev \
  62. # psutil
  63. linux-headers \
  64. # psycopg2
  65. postgresql \
  66. postgresql-dev \
  67. # python-ldap
  68. openldap-dev \
  69. # Sass, compass
  70. libffi-dev \
  71. ruby-dev \
  72. # CSS preprocessors
  73. && gem install --clear-sources --no-document bootstrap-sass compass \
  74. && npm install -g less \
  75. # Build and install Odoo dependencies with pip
  76. # HACK Some modules cannot be installed with PYTHONOPTIMIZE=2
  77. && PYTHONOPTIMIZE=1 pip install --no-cache-dir \
  78. # HACK https://github.com/giampaolo/psutil/issues/948
  79. psutil==2.2.0 \
  80. # HACK https://github.com/erocarrera/pydot/issues/145
  81. pydot==1.0.2 \
  82. # HACK https://github.com/psycopg/psycopg2/commit/37d80f2c0325951d3ee6b07caf7d343d4a97a23d
  83. # TODO Remove in psycopg2>=2.6
  84. psycopg2==2.5.4 \
  85. # HACK https://github.com/eventable/vobject/pull/19
  86. # TODO Remove in vobject>=0.9.3
  87. vobject==0.6.6
  88. # Install Odoo
  89. RUN adduser -D odoo
  90. RUN mkdir -p /tmp/odoo \
  91. && mkdir -p /opt/odoo \
  92. && curl -sL "$ODOO_URI" \
  93. | tar xz -C /tmp/odoo --strip 1
  94. WORKDIR /tmp/odoo
  95. RUN pip install --no-cache-dir -r ./requirements.txt \
  96. && pip install --no-cache-dir . \
  97. && mv ./addons /opt/odoo \
  98. && chown -R odoo /opt/odoo
  99. RUN mkdir -p /etc/odoo \
  100. /mnt/addons \
  101. /opt/addons \
  102. /opt/community \
  103. /var/lib/odoo \
  104. /var/log/odoo \
  105. && ln -sf /dev/stdout "$ODOO_LOG" \
  106. && chown odoo -R /etc/odoo \
  107. /mnt/addons \
  108. /opt/addons \
  109. /opt/community \
  110. /var/lib/odoo \
  111. /var/log/odoo
  112. # Upgrade pillow, old versions cause zlib issues for some reason
  113. RUN CFLAGS="$CFLAGS -L/lib" pip install --no-cache-dir --upgrade pillow
  114. # OCA Repos
  115. RUN curl -sL "$MQT_URI" | tar -xz -C /opt/ \
  116. && ln -s /opt/maintainer-quality-tools-*/travis/clone_oca_dependencies /usr/bin \
  117. && ln -s /opt/maintainer-quality-tools-*/travis/getaddons.py /usr/bin/get_addons \
  118. && chmod +x /usr/bin/get_addons
  119. # Remove unneeded build dependencies
  120. # Re-enable once better binary dependency resolution
  121. #RUN rm -Rf /tmp/odoo \
  122. # && cp /usr/bin/pg_dump /tmp \
  123. # && cp /usr/bin/pg_restore /tmp \
  124. # && apk del .build-deps \
  125. # && mv /tmp/pg_dump /usr/bin/pg_dump \
  126. # && mv /tmp/pg_restore /usr/bin/pg_restore
  127. # WDB debugger
  128. RUN pip install --no-cache-dir wdb
  129. # Other facilities
  130. RUN apk add --no-cache bash gettext postgresql-client
  131. RUN pip install --no-cache-dir openupgradelib
  132. # Copy Entrypoint & Odoo conf
  133. COPY ./docker-entrypoint.sh /docker-entrypoint.sh
  134. #COPY ./etc/odoo-server.conf "$ODOO_CONFIG"
  135. RUN chown odoo /docker-entrypoint.sh \
  136. && chmod +x /docker-entrypoint.sh \
  137. && chown odoo -R "$ODOO_CONFIG_DIR"
  138. # Move binary to new location and symlink old
  139. RUN if [ "$ODOO_VERSION" != "10.0" ]; \
  140. then \
  141. mv /usr/local/bin/openerp-server /usr/local/bin/odoo && \
  142. ln -s /usr/local/bin/odoo /usr/local/bin/openerp-server; \
  143. fi
  144. # Fix stack size overflow
  145. # https://github.com/python-pillow/Pillow/issues/1935
  146. RUN awk '/import odoo/ { print; print "import threading; threading.stack_size(4*80*1024)"; next }1' /usr/local/bin/odoo > /tmp-bin \
  147. && mv /tmp-bin /usr/local/bin/odoo \
  148. && chmod +x /usr/local/bin/odoo
  149. # Mount Volumes
  150. VOLUME ["/var/lib/odoo", "/mnt/addons"]
  151. # Expose Odoo services
  152. EXPOSE 8069 8071
  153. # Entrypoint & Cmd
  154. ENTRYPOINT ["/docker-entrypoint.sh"]
  155. CMD ["odoo"]