Dockerfile 1.9 KB

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