You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
changedetection.io/Dockerfile

94 lines
3.5 KiB

# pip dependencies install stage
# @NOTE! I would love to move to 3.11 but it breaks the async handler in changedetectionio/content_fetchers/puppeteer.py
# If you know how to fix it, please do! and test it for both 3.10 and 3.11
ARG PYTHON_VERSION=3.11
FROM python:${PYTHON_VERSION}-slim-bookworm AS builder
# See `cryptography` pin comment in requirements.txt
ARG CRYPTOGRAPHY_DONT_BUILD_RUST=1
RUN apt-get update && apt-get install -y --no-install-recommends \
g++ \
gcc \
libc-dev \
libffi-dev \
libjpeg-dev \
libssl-dev \
libxslt-dev \
make \
zlib1g-dev
RUN mkdir /install
WORKDIR /install
COPY requirements.txt /requirements.txt
# --extra-index-url https://www.piwheels.org/simple is for cryptography module to be prebuilt (or rustc etc needs to be installed)
RUN pip install --extra-index-url https://www.piwheels.org/simple --target=/dependencies -r /requirements.txt
# Playwright is an alternative to Selenium
# Excluded this package from requirements.txt to prevent arm/v6 and arm/v7 builds from failing
# https://github.com/dgtlmoon/changedetection.io/pull/1067 also musl/alpine (not supported)
RUN pip install --target=/dependencies playwright~=1.41.2 \
|| echo "WARN: Failed to install Playwright. The application can still run, but the Playwright option will be disabled."
# Final image stage
FROM python:${PYTHON_VERSION}-slim-bookworm
LABEL org.opencontainers.image.source="https://github.com/dgtlmoon/changedetection.io"
RUN set -ex; \
apt-get update && apt-get install -y --no-install-recommends \
gosu \
libxslt1.1 \
# For presenting price amounts correctly in the restock/price detection overview
locales \
# For pdftohtml
poppler-utils \
zlib1g && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*; \
useradd -u 911 -U -m -s /bin/false changedetection && \
usermod -G users changedetection; \
mkdir -p /datastore
# Re #80, sets SECLEVEL=1 in openssl.conf to allow monitoring sites with weak/old cipher suites
RUN sed -i 's/^CipherString = .*/CipherString = DEFAULT@SECLEVEL=1/' /etc/ssl/openssl.cnf
# Copy modules over to the final image and add their dir to PYTHONPATH
COPY --from=builder /dependencies /usr/local
ENV PYTHONPATH=/usr/local \
# https://stackoverflow.com/questions/58701233/docker-logs-erroneously-appears-empty-until-container-stops
PYTHONUNBUFFERED=1 \
# https://stackoverflow.com/questions/64808915/should-pycache-folders-be-included-in-production-containers
# This avoids permission denied errors because the app directory is root-owned.
PYTHONDONTWRITEBYTECODE=1 \
DATASTORE_PATH="/datastore" \
# Disable creation of Pytest cache dir when running tests inside the container by default
PYTEST_ADDOPTS="-p no:cacheprovider"
EXPOSE 5000
# The entrypoint script handling PUID/PGID and permissions
COPY --chmod=755 docker-entrypoint.sh /app/docker-entrypoint.sh
# The actual flask app module
COPY changedetectionio /app/changedetectionio
# Starting wrapper
COPY changedetection.py /app/changedetection.py
# create test directory for pytest to run in
RUN mkdir -p /app/changedetectionio/test-datastore && \
chown changedetection:changedetection /app/changedetectionio/test-datastore
# Github Action test purpose(test-only.yml).
# On production, it is effectively LOGGER_LEVEL=''.
ARG LOGGER_LEVEL=''
ENV LOGGER_LEVEL "$LOGGER_LEVEL"
WORKDIR /app
ENTRYPOINT ["/app/docker-entrypoint.sh"]
CMD ["python", "./changedetection.py", "-d", "/datastore"]