orbisk/django-test

By orbisk

•Updated 3 days ago

Django pyton test image with all database installs

Image
Languages & frameworks
Integration & delivery
Databases & storage
0

100K+

orbisk/django-test repository overview

singularIT Logo ⁠

Website⁠ | Blog⁠ | Team⁠

⁠Why?

The official Python images, which are widely used for software development, may not come with all the necessary dependencies to run Django tests out of the box. This can put a strain on developers who need to set up a CI pipeline, particularly when trying to use MySQL, MariaDB, or Postgres as services. To work around this issue, developers need to be aware that they may need to install additional dependencies or configure their CI pipeline in a way that allows these dependencies to be installed at runtime. This can add extra steps to the development process and may require additional troubleshooting to ensure that everything is working correctly.

This image is designed to provide you with a convenient and efficient way to work with MySQL databases in CI. The image comes with a preinstalled MySQL config, which means you can get up and running with your database quickly and easily. In addition, we've included all the necessary clients, such as mysql-client, to ensure you have everything you need to get started.

⁠Features

  • šŸ Python 3.7 - 3.14
  • āš”ļø uv⁠ preinstalled
  • šŸ—ļø Build dependencies preinstalled
  • šŸ”„ CI/CD ready
  • 🐘 Postgres support
  • 🦭 MariaDB support
  • 🐬 MySQL support
  • šŸ¢ MSSQL support (beta)

⁠Compatibility

  • 🟢 Supported/Tested
  • 🟔 Unknown/Untested
  • 🟠 Beta/Experimental (please share your experiences)
  • šŸ”“ Currently not Supported (open an Issue or Pull request if needed)
Python versionuv preinstalled
^3.14.3🟢🟢
^3.13.0🟢🟢
^3.12.4🟢🟢 (^3.12.7)
^3.11.2🟢🟢 (^3.11.10)
^3.10.10🟢🟢 (^3.10.15)
^3.9.16🟢🟢 (^3.9.20)
^3.8.16🟢🟢 (^3.8.20)
^3.7.16🟔 (see⁠)šŸ”“
^2.xšŸ”“šŸ”“

Every Python version (3.8 - 3.14) is tested against every database version listed below in CI.

MySQL*ļøāƒ£
^9.7.0🟢
^8.4.0🟢
^8.0.0 EOL🟔
<=5.7 EOL🟔
MariaDB*ļøāƒ£
^12.3.0🟢
^11.8.0🟢
^11.4.0🟢
^10.11.0🟢
<10.11 EOL🟔
Postgres
^18.0🟢
^17.0🟢
^16.0🟢
^15.0🟢
^14.0🟢
<14🟔
MSSQL (see⁠)
2025🟢
2022🟢
2019🟢
<=2017🟠

*ļøāƒ£ Additional step required see: Error creating the test database⁠

⁠Common issues

⁠Error creating the test database

Got an error creating the test database: (1044, "1044 (42000): Access denied for user '<test_user>'@'%' to database 'test_<my_db>'", '42000')

The MYSQL user is only granted permissions for the MYSQL_DB, which means that Django is unable to create a test database. To use MySQL and MariaDB with a non-root user, you need to grant privileges to your test user.

echo "GRANT ALL on *.* to '$MYSQL_USER';"| mysql -u root --password="$MYSQL_ROOT_PASSWORD" -h <host> -p <port>

⁠CI Examples

⁠GitLab CI
variables:
  MARIADB_USER: test_user
  MARIADB_PASSWORD: password
  MARIADB_ROOT_PASSWORD: root@password
  MARIADB_DATABASE: my_db

django-tests:
  image: orbisk/django-test:3.11
  stage: test
  services:
    - name: mariadb:11.8
      alias: maria
  script:
    - pip3 install -r requirements.txt
    # The MYSQL user only gets permissions for MYSQL_DB, so Django can't create a test database.
    - echo "GRANT ALL on *.* to '$MARIADB_USER';"| mysql -u root --password="$MARIADB_ROOT_PASSWORD" -h maria
    - python3 manage.py test

⁠Feedback

If you have any problems with or questions about this image, please open an issue on GitHub.

⁠MSSQL Beta

āš ļø The MSSQL support is currently in beta. If you have any problems with or questions about this image, please open an issue on GitHub.

MSSQL is currently only supported/tested with the following versions:

⁠Self-signed certificates with ODBC Driver 18

ODBC Driver 18 enables encryption by default and validates the server certificate. The official mcr.microsoft.com/mssql/server image ships with a self-signed cert, so connections fail with SSL Provider: certificate verify failed: self-signed certificate.

For CI/test usage, pass TrustServerCertificate=yes via the Django database OPTIONS:

DATABASES = {
    "mssql": {
        "ENGINE": "mssql",
        # ...
        "OPTIONS": {
            "extra_params": "TrustServerCertificate=yes",
        },
    },
}

Alternatively, set Encrypt=no to disable TLS entirely (matches Driver 17's old default). Do not use either option in production — provide a CA-signed certificate instead.

⁠Limitations

⁠Python 3.7

Python 3.7 is not covered by our CI/CD tests anymore. This means that we can't guarantee that the image will work as expected with Python 3.7. The reason is that packages like mssql-django dropped support for Python 3.7, so we can't test it anymore.

Tag summary

Content type

Image

Digest

sha256:4e682aa08…

Size

462.8 MB

Last updated

3 days ago

docker pull orbisk/django-test:3.13.14