Skip to content

Commit

Permalink
Merge pull request #1015 from ix5/py3.12-docker-venv
Browse files Browse the repository at this point in the history
Python 3.12 compatibility; docker, venv/virtualenv
  • Loading branch information
ix5 authored May 5, 2024
2 parents ed7a0d5 + a4a780c commit 33ad1fb
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 33 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
os: [ubuntu-latest, macos-latest]
# Use only lowest and highest supported python versions for now,
# to speed up CI runs
python-version: [3.8, "3.11"]
python-version: [3.8, "3.12"]
node-version: [16]
fail-fast: false

Expand Down Expand Up @@ -47,6 +47,7 @@ jobs:
- name: Generate Isso package
id: generate-package
run: |
pip install setuptools
python setup.py sdist
echo "::set-output name=package_file::$(ls dist/)"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.8, 3.9, "3.10", "3.11"]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
fail-fast: false

steps:
Expand Down
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Bugfixes & Improvements
- Add link logging for management of new comments in Stdout (`#1016`_, pkvach)
- Change logging to include datetime and loglevel (`#1023`_, ix5)
- Make 'text' field in 'comments' table NOT NULL and handling data migration (`#1019`_, pkvach)
- Python 3.12 support (`#1015`_, ix5)

.. _#951: https://github.com/posativ/isso/pull/951
.. _#967: https://github.com/posativ/isso/pull/967
Expand All @@ -58,6 +59,7 @@ Bugfixes & Improvements
.. _#1016: https://github.com/isso-comments/isso/pull/1016
.. _#1023: https://github.com/isso-comments/isso/pull/1023
.. _#1019: https://github.com/isso-comments/isso/pull/1019
.. _#1015: https://github.com/isso-comments/isso/pull/1015

0.13.1.dev0 (2023-02-05)
------------------------
Expand Down
41 changes: 25 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Isso production Dockerfile

ARG PY_VERSION=3.12

# =======================================================
# First stage: Build Javascript client parts using NodeJS
# =======================================================

FROM node:current-alpine AS isso-js
FROM docker.io/node:current-alpine AS isso-js
WORKDIR /src/

# make is not installed by default on alpine
Expand All @@ -23,34 +27,36 @@ COPY ["isso/js/", "./isso/js/"]
# Run webpack to generate minified Javascript
RUN make js


# ==================================================
# Second stage: Create production-ready Isso package
# ==================================================

# Copy needed files
FROM python:3.10-alpine AS isso-builder
FROM docker.io/python:${PY_VERSION}-alpine AS isso-builder
WORKDIR /isso/

# Set up virtualenv
RUN python3 -m venv /isso \
&& . /isso/bin/activate \
&& pip3 install --no-cache-dir --upgrade pip \
&& pip3 install --no-cache-dir gunicorn

# Install cffi dependencies since they're not present on alpine by default
# (required by cffi which in turn is required by misaka)
RUN apk add --no-cache gcc libffi-dev libc-dev

# For some reason, it is required to install cffi before misaka, else pip will
# fail to build cffi
RUN . /isso/bin/activate \
&& pip3 install cffi
# Use pip from /usr/local/lib to install virtualenv from PyPI
# (Do not use the alpine py3-virtualenv package which would be stuck on the
# Python version from the alpine repos (3.9 as of May 2024), otherwise there
# would be a mismatch between PY_VERSION and the virtualenv used)
RUN pip install virtualenv

# # Set up virtualenv
RUN virtualenv --download /isso \
&& . /isso/bin/activate \
&& pip install --no-cache-dir --upgrade pip gunicorn cffi

# Install Isso's python dependencies via pip in a separate step before copying
# over client files, so that changing Isso js/python source code will not
# trigger a re-installation of all pip packages from scratch
COPY ["setup.py", "setup.cfg", "README.md", "LICENSE", "./"]
RUN --mount=type=cache,target=/root/.cache \
. /isso/bin/activate \
&& python3 setup.py develop
&& pip install -e .

# Then copy over files
# SRC "isso/" is treated as "isso/*" by docker, so copy to subdir explicitly
Expand All @@ -63,11 +69,14 @@ COPY --from=isso-js /src/isso/js/ ./isso/js
# Build and install Isso package (pip dependencies cached from previous step)
RUN --mount=type=cache,target=/root/.cache \
. /isso/bin/activate \
&& python3 setup.py develop --no-deps
&& pip install -e . --no-deps


# =====================
# Third stage: Run Isso
FROM python:3.10-alpine AS isso
# =====================

FROM docker.io/python:${PY_VERSION}-alpine AS isso
WORKDIR /isso/
COPY --from=isso-builder /isso/ .

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ docker-release-push:
docker push $(ISSO_DOCKER_REGISTRY)/$(ISSO_RELEASE_IMAGE)

docker-testbed:
docker build -f docker/Dockerfile-js-testbed -t $(TESTBED_IMAGE) .
DOCKER_BUILDKIT=1 docker build -f docker/Dockerfile-js-testbed -t $(TESTBED_IMAGE) .

# For maintainers only:
docker-testbed-push:
Expand Down
3 changes: 0 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# https://docs.docker.com/compose/compose-file/compose-file-v3/
version: "3.9"

services:

# Isso server should always reflect production image
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/contributing/documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Install via pip:

.. code-block:: console
$ virtualenv .venv && $ source .venv/bin/activate
$ virtualenv --download .venv && $ source .venv/bin/activate
(.venv) $ pip install sphinx
(.venv) $ sphinx-build --version
~> sphinx-build 4.5.0
Expand Down Expand Up @@ -157,7 +157,7 @@ Use ``.. code-block:: <language>`` and indent the code by one level:
.. code-block:: console
$ sudo apt install python3 python3-pip python3-virtualenv
$ virtualenv .venv
$ virtualenv --download .venv
$ source .venv/bin/activate
(.venv) $ python [cmd]
Expand Down
12 changes: 6 additions & 6 deletions docs/docs/reference/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ but not recommended):

.. code-block:: console
$ virtualenv /opt/isso
$ virtualenv --download /opt/isso
$ source /opt/isso/bin/activate
.. note::
Expand Down Expand Up @@ -82,7 +82,7 @@ Install from PyPi
Requirements
^^^^^^^^^^^^

- Python 3.8+ (+ devel headers)
- Python 3.8+ (+ devel headers) and Virtualenv
- SQLite 3.3.8 or later
- a working C compiler

Expand All @@ -91,13 +91,13 @@ For Debian/Ubuntu just `copy and paste

.. code-block:: console
$ sudo apt-get install python3-dev sqlite3 build-essential
$ sudo apt-get install python3-dev python3-virtualenv sqlite3 build-essential
Similar for Fedora (and derivates):

.. code-block:: console
$ sudo yum install python3-devel sqlite
$ sudo yum install python3-devel python3-virtualenv sqlite
$ sudo yum groupinstall “Development Tools”
Installation
Expand Down Expand Up @@ -216,7 +216,7 @@ To create a virtual environment (recommended), run:

.. code-block:: console
$ virtualenv .venv
$ virtualenv --download .venv
$ source .venv/bin/activate
Install JavaScript modules using ``npm``:
Expand All @@ -235,7 +235,7 @@ Install Isso and its dependencies:

.. code-block:: console
(.venv) $ python setup.py develop # or `pip install -e .`
(.venv) $ pip install -e . # -e = "editable" installation for development
(.venv) $ isso -c /path/to/isso.cfg run
.. _init-scripts:
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/technical-docs/testing-client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Start the server and ensure that the comment database is empty:
.. code-block:: bash
$ mv comments.db comments.db.bak
$ virtualenv .venv
$ virtualenv --download .venv
$ source .venv/bin/activate
(.venv) $ isso -c contrib/isso-dev.cfg run
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/technical-docs/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ a development server available at ``localhost:8080``.

.. code-block:: bash
$ virtualenv .venv
$ virtualenv --download .venv
$ source .venv/bin/activate
(.venv) $ isso -c contrib/isso-dev.cfg run
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
install_requires=[
'itsdangerous', 'Jinja2', 'misaka>=2.0,<3.0', 'html5lib',
'werkzeug>=1.0', 'bleach'],
'werkzeug>=1.0', 'bleach', 'setuptools'],
tests_require=['pytest', 'pytest-cov'],
extras_require={
'doc': ['Sphinx'],
Expand Down

0 comments on commit 33ad1fb

Please sign in to comment.