Dockerfile 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.8
  14. ###
  15. ### Stage 0: builder
  16. ###
  17. FROM docker.io/python:${PYTHON_VERSION}-slim as builder
  18. # install the OS build deps
  19. RUN apt-get update && apt-get install -y \
  20. build-essential \
  21. libffi-dev \
  22. libjpeg-dev \
  23. libpq-dev \
  24. libssl-dev \
  25. libwebp-dev \
  26. libxml++2.6-dev \
  27. libxslt1-dev \
  28. rustc \
  29. zlib1g-dev \
  30. && rm -rf /var/lib/apt/lists/*
  31. # Build dependencies that are not available as wheels, to speed up rebuilds
  32. RUN pip install --prefix="/install" --no-warn-script-location \
  33. cryptography \
  34. frozendict \
  35. jaeger-client \
  36. opentracing \
  37. # Match the version constraints of Synapse
  38. "prometheus_client>=0.4.0" \
  39. psycopg2 \
  40. pycparser \
  41. pyrsistent \
  42. pyyaml \
  43. simplejson \
  44. threadloop \
  45. thrift
  46. # now install synapse and all of the python deps to /install.
  47. COPY synapse /synapse/synapse/
  48. COPY scripts /synapse/scripts/
  49. COPY MANIFEST.in README.rst setup.py synctl /synapse/
  50. RUN pip install --prefix="/install" --no-warn-script-location \
  51. /synapse[all]
  52. ###
  53. ### Stage 1: runtime
  54. ###
  55. FROM docker.io/python:${PYTHON_VERSION}-slim
  56. RUN apt-get update && apt-get install -y \
  57. curl \
  58. gosu \
  59. libjpeg62-turbo \
  60. libpq5 \
  61. libwebp6 \
  62. xmlsec1 \
  63. libjemalloc2 \
  64. && rm -rf /var/lib/apt/lists/*
  65. COPY --from=builder /install /usr/local
  66. COPY ./docker/start.py /start.py
  67. COPY ./docker/conf /conf
  68. VOLUME ["/data"]
  69. EXPOSE 8008/tcp 8009/tcp 8448/tcp
  70. ENTRYPOINT ["/start.py"]
  71. HEALTHCHECK --interval=1m --timeout=5s \
  72. CMD curl -fSs http://localhost:8008/health || exit 1