Dockerfile 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. ARG PYTHON_VERSION=2
  2. ###
  3. ### Stage 0: builder
  4. ###
  5. FROM docker.io/python:${PYTHON_VERSION}-alpine3.8 as builder
  6. # install the OS build deps
  7. RUN apk add \
  8. build-base \
  9. libffi-dev \
  10. libjpeg-turbo-dev \
  11. libressl-dev \
  12. libxslt-dev \
  13. linux-headers \
  14. postgresql-dev \
  15. zlib-dev
  16. # build things which have slow build steps, before we copy synapse, so that
  17. # the layer can be cached.
  18. #
  19. # (we really just care about caching a wheel here, as the "pip install" below
  20. # will install them again.)
  21. RUN pip install --prefix="/install" --no-warn-script-location \
  22. cryptography \
  23. msgpack-python \
  24. pillow \
  25. pynacl
  26. # now install synapse and all of the python deps to /install.
  27. COPY . /synapse
  28. RUN pip install --prefix="/install" --no-warn-script-location \
  29. lxml \
  30. psycopg2 \
  31. /synapse
  32. ###
  33. ### Stage 1: runtime
  34. ###
  35. FROM docker.io/python:${PYTHON_VERSION}-alpine3.8
  36. RUN apk add --no-cache --virtual .runtime_deps \
  37. libffi \
  38. libjpeg-turbo \
  39. libressl \
  40. libxslt \
  41. libpq \
  42. zlib \
  43. su-exec
  44. COPY --from=builder /install /usr/local
  45. COPY ./docker/start.py /start.py
  46. COPY ./docker/conf /conf
  47. VOLUME ["/data"]
  48. EXPOSE 8008/tcp 8448/tcp
  49. ENTRYPOINT ["/start.py"]