Skip to content

Commit

Permalink
update Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
yingziwu committed Jan 17, 2024
1 parent d2a3f9b commit 1a2929d
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
# `poetry export | pip install -r /dev/stdin`, but beware: we have experienced bugs in
# in `poetry export` in the past.

ARG PYTHON_VERSION=3.10
ARG PYTHON_VERSION=3.11

###
### Stage 0: generate requirements.txt
###
# We hardcode the use of Debian bookworm here because this could change upstream
# and other Dockerfiles used for testing are expecting bookworm.
FROM pypy:${PYTHON_VERSION}-slim-bookworm as requirements
FROM docker.io/library/python:${PYTHON_VERSION}-slim-bookworm as requirements

# RUN --mount is specific to buildkit and is documented at
# https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/syntax.md#build-mounts-run---mount.
Expand Down Expand Up @@ -65,13 +65,11 @@ WORKDIR /synapse
# Copy just what we need to run `poetry export`...
COPY pyproject.toml poetry.lock /synapse/


# Install custom extensions
RUN /root/.local/bin/poetry add --lock -- \
"git+https://github.com/devture/matrix-synapse-shared-secret-auth#master" \
"git+https://github.com/matrix-org/mjolnir.git#main&subdirectory=synapse_antispam"


# If specified, we won't verify the hashes of dependencies.
# This is only needed if the hashes of dependencies cannot be checked for some
# reason, such as when a git repository is used directly as a dependency.
Expand All @@ -85,15 +83,15 @@ ARG TEST_ONLY_IGNORE_POETRY_LOCKFILE
# Otherwise, just create an empty requirements file so that the Dockerfile can
# proceed.
RUN if [ -z "$TEST_ONLY_IGNORE_POETRY_LOCKFILE" ]; then \
/root/.local/bin/poetry export --without-hashes --extras all -o /synapse/requirements.txt ${TEST_ONLY_SKIP_DEP_HASH_VERIFICATION:+--without-hashes}; \
/root/.local/bin/poetry export --extras all -o /synapse/requirements.txt --without-hashes; \
else \
touch /synapse/requirements.txt; \
fi

###
### Stage 1: builder
###
FROM pypy:${PYTHON_VERSION}-slim-bookworm as builder
FROM docker.io/library/python:${PYTHON_VERSION}-slim-bookworm as builder

# install the OS build deps
RUN \
Expand Down Expand Up @@ -164,7 +162,7 @@ RUN --mount=type=cache,target=/synapse/target,sharing=locked \
### Stage 2: runtime
###

FROM pypy:${PYTHON_VERSION}-slim-bookworm
FROM docker.io/library/python:${PYTHON_VERSION}-slim-bookworm

LABEL org.opencontainers.image.url='https://matrix.org/docs/projects/server/synapse'
LABEL org.opencontainers.image.documentation='https://github.com/element-hq/synapse/blob/master/docker/README.md'
Expand All @@ -187,18 +185,13 @@ RUN \
openssl \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder /install /opt/pypy
COPY --from=builder /install /usr/local
COPY ./docker/start.py /start.py
COPY ./docker/conf /conf


# Patch for pypy
RUN pip uninstall -y psycopg2 pympler


EXPOSE 8008/tcp 8009/tcp 8448/tcp

ENTRYPOINT ["/start.py"]

HEALTHCHECK --start-period=5s --interval=15s --timeout=5s \
CMD curl -fSs http://localhost:8008/health || exit 1
CMD curl -fSs http://localhost:8008/health || exit 1

0 comments on commit 1a2929d

Please sign in to comment.