jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[IMPR] Update Dockerfile to Python 3.8

- Use official Python base image instead of building our own from
Debian.
- Bump to Python 3.8.
- Use a smaller base image version, `-slim` (253MB instead of 1.05GB).
- Some dev dependencies (`dev-requirements.txt`) like PIL can't be
installed in smaller base image, so create a second dockerfile named
Dockerfile-dev, that also loads dev-requirements.txt file.
- Update CONTENT.rst with new file description.
- Set ENTRYPOINT to Pywikibot's pwb.py, with `version` argument if
none is specified.
- Set PYTHONPATH env var.
- Remove MAINTAINER tag, deprecated since Docker 1.13.0
https://github.com/lukasmartinelli/hadolint/issues/71.
- Use COPY tag instead of ADD to put files in the container. See
https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#add-or-copy,

Change-Id: I615de3b1cf34b204ae22de2855f0dcfc0a018cd6
---
M CONTENT.rst
M Dockerfile
A Dockerfile-dev
3 files changed, 74 insertions(+), 66 deletions(-)

diff --git a/CONTENT.rst b/CONTENT.rst
index 8ba2abb..e96efb5 100644
--- a/CONTENT.rst
+++ b/CONTENT.rst
@@ -1,52 +1,54 @@
The contents of the package
---------------------------

- +----------------------------------------------------------------------------------+
- | README and config files: |
- +===========================+======================================================+
- | CODE_OF_CONDUCT.md | Code of conduct reference |
- +---------------------------+------------------------------------------------------+
- | CONTENT.rst | This Content description file |
- +---------------------------+------------------------------------------------------+
- | CREDITS | List of major contributors to this module |
- +---------------------------+------------------------------------------------------+
- | dev-requirements.txt | PIP requirements file for development dependencies |
- +---------------------------+------------------------------------------------------+
- | Dockerfile | assemble an image, install all dependencies via pip |
- +---------------------------+------------------------------------------------------+
- | generate_family_file.py | Creates a new family file. |
- +---------------------------+------------------------------------------------------+
- | generate_user_files.py | Creates user-config.py or user-fixes.py |
- +---------------------------+------------------------------------------------------+
- | HISTORY.rst | pypi version history file |
- +---------------------------+------------------------------------------------------+
- | LICENSE | a reference to the MIT license |
- +---------------------------+------------------------------------------------------+
- | pwb.py | Wrapper script to use Pywikibot in 'directory' mode |
- +---------------------------+------------------------------------------------------+
- | README.rst | Short info string used by Pywikibot Nightlies |
- +---------------------------+------------------------------------------------------+
- | README-conversion.txt | Compat to Core branch conversion hints |
- +---------------------------+------------------------------------------------------+
- | requirements.txt | General PIP requirements file |
- +---------------------------+------------------------------------------------------+
- | ROADMAP.rst | pypi version roadmap file |
- +---------------------------+------------------------------------------------------+
- | setup.py | Installer script for Pywikibot framework |
- +---------------------------+------------------------------------------------------+
- | tox.ini | Tests config file |
- +---------------------------+------------------------------------------------------+
- | user-config.py.sample | Example user-config.py file for reference |
- +---------------------------+------------------------------------------------------+
- | user-fixes.py.sample | Example user-fixes.py file for reference |
- +---------------------------+------------------------------------------------------+
+ +---------------------------------------------------------------------------------------+
+ | README and config files: |
+ +===========================+===========================================================+
+ | CODE_OF_CONDUCT.md | Code of conduct reference |
+ +---------------------------+-----------------------------------------------------------+
+ | CONTENT.rst | This Content description file |
+ +---------------------------+-----------------------------------------------------------+
+ | CREDITS | List of major contributors to this module |
+ +---------------------------+-----------------------------------------------------------+
+ | dev-requirements.txt | PIP requirements file for development dependencies |
+ +---------------------------+-----------------------------------------------------------+
+ | Dockerfile | Assemble a Docker image, install all dependencies via pip |
+ +---------------------------+-----------------------------------------------------------+
+ | Dockerfile-dev | Docker image including developement dependencies |
+ +---------------------------+-----------------------------------------------------------+
+ | generate_family_file.py | Creates a new family file |
+ +---------------------------+-----------------------------------------------------------+
+ | generate_user_files.py | Creates user-config.py or user-fixes.py |
+ +---------------------------+-----------------------------------------------------------+
+ | HISTORY.rst | pypi version history file |
+ +---------------------------+-----------------------------------------------------------+
+ | LICENSE | Reference to the MIT license |
+ +---------------------------+-----------------------------------------------------------+
+ | pwb.py | Wrapper script to use Pywikibot in 'directory' mode |
+ +---------------------------+-----------------------------------------------------------+
+ | README.rst | Short info string used by Pywikibot Nightlies |
+ +---------------------------+-----------------------------------------------------------+
+ | README-conversion.txt | Compat to Core branch conversion hints |
+ +---------------------------+-----------------------------------------------------------+
+ | requirements.txt | General PIP requirements file |
+ +---------------------------+-----------------------------------------------------------+
+ | ROADMAP.rst | pypi version roadmap file |
+ +---------------------------+-----------------------------------------------------------+
+ | setup.py | Installer script for Pywikibot framework |
+ +---------------------------+-----------------------------------------------------------+
+ | tox.ini | Tests config file |
+ +---------------------------+-----------------------------------------------------------+
+ | user-config.py.sample | Example user-config.py file for reference |
+ +---------------------------+-----------------------------------------------------------+
+ | user-fixes.py.sample | Example user-fixes.py file for reference |
+ +---------------------------+-----------------------------------------------------------+

- +----------------------------------------------------------------------------------+
- | Directories |
- +===========================+======================================================+
- | pywikibot | Contains some libraries and control files |
- +---------------------------+------------------------------------------------------+
- | scripts | Contains all bots and utility scripts |
- +---------------------------+------------------------------------------------------+
- | tests | Some test stuff for the developing team |
- +---------------------------+------------------------------------------------------+
+ +---------------------------------------------------------------------------------------+
+ | Directories |
+ +===========================+===========================================================+
+ | pywikibot | Contains some libraries and control files |
+ +---------------------------+-----------------------------------------------------------+
+ | scripts | Contains all bots and utility scripts |
+ +---------------------------+-----------------------------------------------------------+
+ | tests | Some test stuff for the developing team |
+ +---------------------------+-----------------------------------------------------------+
diff --git a/Dockerfile b/Dockerfile
index 0ec66fa..656071a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,23 +1,14 @@
-FROM debian:stretch
+FROM python:3.8-slim

-MAINTAINER Pywikibot team <pywikibot@lists.wikimedia.org>
+WORKDIR /code

-RUN apt-get update
-RUN apt-get install --yes python3.5 python3-pip git libjpeg62-turbo libjpeg62-turbo-dev zlib1g zlib1g-dev locales
+COPY requirements.txt .
+RUN pip install -r requirements.txt

-# Setup the C.UTF-8 Locale, since otherwise it defaults to an ASCII one
-RUN locale-gen C.UTF-8
-ENV LC_ALL C.UTF-8
+COPY . .
+RUN pip3 install .

-# TODO: Add this to the default PYTHONPATH and PATH?
-ADD . /srv/pwb
+ENV PYTHONPATH=/code:/code/scripts

-# pip version in stretch is too old :(
-RUN pip3 install -U setuptools
-RUN pip3 install -U pip
-
-RUN pip3 install -r /srv/pwb/requirements.txt
-RUN pip3 install -r /srv/pwb/dev-requirements.txt
-RUN pip3 install /srv/pwb/
-
-CMD /bin/bash
\ No newline at end of file
+ENTRYPOINT ["python", "/code/pwb.py"]
+CMD ["version"]
diff --git a/Dockerfile-dev b/Dockerfile-dev
new file mode 100644
index 0000000..b68f42f
--- /dev/null
+++ b/Dockerfile-dev
@@ -0,0 +1,15 @@
+FROM python:3.8
+
+WORKDIR /code
+
+COPY requirements.txt .
+COPY dev-requirements.txt .
+RUN pip install -r requirements.txt
+RUN pip install -r dev-requirements.txt
+
+COPY . .
+RUN pip3 install .
+
+ENV PYTHONPATH=/code:/code/scripts
+ENTRYPOINT ["python", "/code/pwb.py"]
+CMD ["version"]

To view, visit change 621357. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I615de3b1cf34b204ae22de2855f0dcfc0a018cd6
Gerrit-Change-Number: 621357
Gerrit-PatchSet: 3
Gerrit-Owner: Framawiki <framawiki@tools.wmflabs.org>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged