osmose-backend icon indicating copy to clipboard operation
osmose-backend copied to clipboard

Changes needed to build with older versions of Docker

Open kidhanis opened this issue 4 months ago • 1 comments

I’m using an old version of macOS (High Sierra). Newer Docker bundles are not compatible with High Sierra, so I’m currently testing with Docker Toolbox 19.03.1, which was released when High Sierra was still supported.

This Docker Toolbox package contains docker 19.03.1, docker-compose 1.24.1, and docker-machine 0.16.1.

After reading the Docker setup, I expected these older versions of Docker to be sufficient, but the build didn’t work with the code as-is.

I have to make two changes to the code in order to successfully build the backend image:

  1. Changing FROM python:3.11 to FROM python:3.9-bullseye in docker/Dockerfile#L1
  2. Installing the most recent version of PyKOpeningHours by deleting @24.01.90 in requirements.txt#12

Explanation of changes

Python image variant

The first line in the Dockerfile calls the python:3.11 image. When using this image for docker-compose build, I get GPG errors after executing apt-get update (line 3 in the Dockerfile): "signatures couldn't be verified because the public key is not available"

I traced this error back to a change that Docker made to the Python images, including python:3.11 and python:3.9. The underlying Debian version used to build these Python images was changed from 11 (Bullseye) to 12 (Bookworm). This change means that I'd need to upgrade Docker to continue building with python:3.11.

I then tried to use an image variant of Python, as suggested in the https://hub.docker.com/_/python:

Image Variants ... Some of these tags may have names like bookworm or bullseye in them. These are the suite code names for releases of Debian and indicate which release the image is based on. If your image needs to install any additional packages beyond what comes with the image, you'll likely want to specify one of these explicitly to minimize breakage when there are new releases of Debian.

I can’t use python:3.11-bullseye because step 5 (Dockerfile line 39) would throw the same error from #1858, as libboost-python-dev from Bullseye uses python3.9. Therefore, I went with python:3.9-bullseye.

PyKOpeningHours error

The build now stops at step 10 (Dockerfile line 46) because pip fails to install version 24.01.90 of PyKOpeningHours. There’s an error due to a requested module (ECMQmlModule) that’s present in the Bookworm version of extra-cmake-modules but not in the Bullseye version.

Fortunately, the next version of PyKOpeningHours will request this module only when needed. In the meantime, I can switch to the latest commit of PyKOpeningHours.

With this final change, step 10 clears and now the backend builds successfully.

kidhanis avatar Mar 19 '24 05:03 kidhanis

Updating pyKOpeningHours is planned as soon as there's a new tagged release: #2136 😉

Famlam avatar Mar 19 '24 09:03 Famlam

pyKOpeningHours has been updated to the latest version, which should also resolve the issue you describe with pyKOpeningHours.

For the Python version, I'm not sure what's the best approach. The best I can think of is a section in the docs about compatibility and how to work around it for older/unsupported OS? I don't think we'll downgrade to a lower Python version.

Famlam avatar Apr 27 '24 12:04 Famlam

I suggest at this point to do nothing more.

frodrigo avatar Apr 27 '24 12:04 frodrigo

Should this sentence in docker/README.md be removed? https://github.com/osm-fr/osmose-backend/blob/e34fc898b9d8ca7bdcb1f83de8aea2c52347cdb7/docker/README.md?plain=1#L19 It works only with a Python image based on an older Debian release, like I mentioned above.

kidhanis avatar Apr 30 '24 19:04 kidhanis

Right, removed. Thank you.

frodrigo avatar May 01 '24 11:05 frodrigo