Dockerfile 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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=2
  14. ###
  15. ### Stage 0: builder
  16. ###
  17. FROM docker.io/python:${PYTHON_VERSION}-alpine3.8 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.8
  48. RUN apk add --no-cache --virtual .runtime_deps \
  49. libffi \
  50. libjpeg-turbo \
  51. libressl \
  52. libxslt \
  53. libpq \
  54. zlib \
  55. su-exec
  56. COPY --from=builder /install /usr/local
  57. COPY ./docker/start.py /start.py
  58. COPY ./docker/conf /conf
  59. VOLUME ["/data"]
  60. EXPOSE 8008/tcp 8009/tcp 8448/tcp
  61. ENTRYPOINT ["/start.py"]