Dockerfile 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # Dockerfile to build the matrixdotorg/synapse docker images.
  2. #
  3. # To build the image, run `docker build` command from the root of the
  4. # synapse repository:
  5. #
  6. # docker build -f docker/Dockerfile .
  7. #
  8. # There is an optional PYTHON_VERSION build argument which sets the
  9. # version of python to build against: for example:
  10. #
  11. # docker build -f docker/Dockerfile --build-arg PYTHON_VERSION=3.6 .
  12. #
  13. ARG PYTHON_VERSION=3.7
  14. ###
  15. ### Stage 0: builder
  16. ###
  17. FROM docker.io/python:${PYTHON_VERSION}-alpine3.11 as builder
  18. # install the OS build deps
  19. RUN apk add \
  20. build-base \
  21. libffi-dev \
  22. libjpeg-turbo-dev \
  23. libressl-dev \
  24. libxslt-dev \
  25. linux-headers \
  26. postgresql-dev \
  27. zlib-dev
  28. # build things which have slow build steps, before we copy synapse, so that
  29. # the layer can be cached.
  30. #
  31. # (we really just care about caching a wheel here, as the "pip install" below
  32. # will install them again.)
  33. RUN pip install --prefix="/install" --no-warn-script-location \
  34. cryptography \
  35. msgpack-python \
  36. pillow \
  37. pynacl
  38. # now install synapse and all of the python deps to /install.
  39. COPY synapse /synapse/synapse/
  40. COPY scripts /synapse/scripts/
  41. COPY MANIFEST.in README.rst setup.py synctl /synapse/
  42. RUN pip install --prefix="/install" --no-warn-script-location \
  43. /synapse[all]
  44. ###
  45. ### Stage 1: runtime
  46. ###
  47. FROM docker.io/python:${PYTHON_VERSION}-alpine3.10
  48. # xmlsec is required for saml support
  49. RUN apk add --no-cache --virtual .runtime_deps \
  50. libffi \
  51. libjpeg-turbo \
  52. libressl \
  53. libxslt \
  54. libpq \
  55. zlib \
  56. su-exec \
  57. tzdata \
  58. xmlsec
  59. COPY --from=builder /install /usr/local
  60. COPY ./docker/start.py /start.py
  61. COPY ./docker/conf /conf
  62. VOLUME ["/data"]
  63. EXPOSE 8008/tcp 8009/tcp 8448/tcp
  64. ENTRYPOINT ["/start.py"]