Skip to content

Commit

Permalink
Use python3.11.5 in production (#2324)
Browse files Browse the repository at this point in the history
* Use `python3.11.5` in production

* Update to 3.11.5-slim-bookworm

* Fix name and description
  • Loading branch information
sobolevn authored Sep 5, 2023
1 parent 8238d04 commit e012da2
Show file tree
Hide file tree
Showing 14 changed files with 525 additions and 561 deletions.
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ include:
# Building template project:
mirror-github-build:
stage: build
image: python:3.9
image: python:3.11.5
variables:
POETRY_VERSION: '1.5.1'
POETRY_VERSION: '1.6.1'
before_script:
# Installing poetry:
- curl -sSL 'https://install.python-poetry.org' | python -
Expand Down
6 changes: 3 additions & 3 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ version: 2
build:
os: ubuntu-20.04
tools:
python: '3.9'
python: '3.11'
jobs:
# See https://github.com/readthedocs/readthedocs.org/issues/4912
pre_create_environment:
# Select Python version (keep in sync with other versions):
- asdf install python 3.9.16
- asdf global python 3.9.16
- asdf install python 3.11.5
- asdf global python 3.11.5
- python -m pip install --upgrade --no-cache-dir virtualenv

# Install poetry:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Just like `django-admin.py startproject` but better.
## Features

- Always [`up-to-date`](https://github.com/wemake-services/wemake-django-template/pulls?utf8=%E2%9C%93&q=is%3Apr%20author%3Aapp%2Fdependabot) with the help of [`@dependabot`](https://dependabot.com/)
- Supports latest `python3.9+`
- Supports latest `python3.11+`
- [`poetry`](https://github.com/python-poetry/poetry) for managing dependencies
- [`mypy`](https://mypy.readthedocs.io) and [`django-stubs`](https://github.com/typeddjango/django-stubs) for static typing
- [`pytest`](https://pytest.org/) and [`hypothesis`](https://github.com/HypothesisWorks/hypothesis) for unit tests
Expand Down
8 changes: 4 additions & 4 deletions {{cookiecutter.project_name}}/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ variables:
- echo "$CI_JOB_TOKEN" | docker login "$REGISTRY"
-u gitlab-ci-token --password-stdin
# Debug information:
- docker info && docker-compose --version && git --version
- docker info && docker compose --version && git --version

# Test scripts
# ============
Expand All @@ -51,14 +51,14 @@ test:
- docker tag "${IMAGE_FULL_NAME}:dev" "${PROJECT_NAME}:dev" || true
script:
# Checking config:
- docker-compose -f docker-compose.yml
- docker compose -f docker-compose.yml
-f docker/docker-compose.prod.yml config --quiet

# Build and run tests:
- docker-compose build
- docker compose build
--build-arg BUILDKIT_INLINE_CACHE=1
--progress=plain web
- docker-compose run --user=root --rm web ./docker/django/ci.sh
- docker compose run --user=root --rm web ./docker/django/ci.sh

# Check the result image size:
- disl "${PROJECT_NAME}:dev" 950MiB
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_name}}/.python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.9.16
3.11.5
7 changes: 3 additions & 4 deletions {{cookiecutter.project_name}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ This project was generated with [`wemake-django-template`](https://github.com/we

You will need:

- `python3.9` (see `pyproject.toml` for full version)
- `postgresql` with version `13`
- `docker` with [version at least](https://docs.docker.com/compose/compose-file/#compose-and-docker-compatibility-matrix) `18.02`
- `python3.11` (see `pyproject.toml` for full version)
- `postgresql` with version `15`
- Latest `docker`


## Development
Expand All @@ -25,7 +25,6 @@ When developing locally, we use:
- [`editorconfig`](http://editorconfig.org/) plugin (**required**)
- [`poetry`](https://github.com/python-poetry/poetry) (**required**)
- [`pyenv`](https://github.com/pyenv/pyenv)
- `pycharm 2017+` or `vscode`


## Documentation
Expand Down
4 changes: 2 additions & 2 deletions {{cookiecutter.project_name}}/docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---

# This docker-compose file is required to bind ports in development,
# This file is required to bind ports in development,
# since binding ports in regular compose file will ruin scaling
# in production. Due to how `ports` directive is merged with two files.
#
# This file is ignored in production, but
# it is automatically picked up in development with:
#
# $ docker-compose up
# $ docker compose up

version: "3.8"
services:
Expand Down
4 changes: 2 additions & 2 deletions {{cookiecutter.project_name}}/docker/django/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This Dockerfile uses multi-stage build to customize DEV and PROD images:
# https://docs.docker.com/develop/develop-images/multistage-build/

FROM python:3.9.16-slim-buster AS development_build
FROM python:3.11.5-slim-bookworm AS development_build

LABEL maintainer="{{ cookiecutter.project_domain }}"
LABEL vendor="{{ cookiecutter.project_domain }}"
Expand All @@ -27,7 +27,7 @@ ENV DJANGO_ENV=${DJANGO_ENV} \
# tini:
TINI_VERSION=v0.19.0 \
# poetry:
POETRY_VERSION=1.5.1 \
POETRY_VERSION=1.6.1 \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_CACHE_DIR='/var/cache/pypoetry' \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Before going any further, please,
take a moment to read the `official documentation <https://poetry.eustace.io/>`_
about ``poetry`` to know some basics.

If you are using ``docker`` then prepend ``docker-compose run --rm web``
If you are using ``docker`` then prepend ``docker compose run --rm web``
before any of those commands to execute them.

Please, note that you don't need almost all of them with ``docker``.
Expand Down Expand Up @@ -105,15 +105,15 @@ To start development server inside ``docker`` you will need to run:
.. code:: bash
export DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 # enable buildkit
docker-compose build
docker-compose run --rm web python manage.py migrate
docker-compose up
docker compose build
docker compose run --rm web python manage.py migrate
docker compose up
Running scripts inside docker
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

As we have already mentioned inside the previous section
we use ``docker-compose run`` to run scripts inside docker.
we use ``docker compose run`` to run scripts inside docker.

What do you need to know about it?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ Here's it would look like:

.. code:: bash
docker-compose -f docker-compose.yml -f docker/docker-compose.prod.yml
run --rm caddy -validate
docker compose -f docker-compose.yml -f docker/docker-compose.prod.yml \
run --rm caddy -validate
This check is not included in the pipeline by default,
because it is quite long to start all the machinery for this single check.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ which is not required into the development build.

.. code:: bash
docker-compose -f docker-compose.yml -f docker/docker-compose.prod.yml up
docker compose -f docker-compose.yml -f docker/docker-compose.prod.yml up
Pulling pre-built images
Expand Down Expand Up @@ -73,5 +73,5 @@ containers.
Further reading
---------------

- Production with `docker-compose <https://docs.docker.com/compose/production>`_
- Production with `docker compose <https://docs.docker.com/compose/production>`_
- `Full tutorial <https://docs.docker.com/get-started>`_
Loading

0 comments on commit e012da2

Please sign in to comment.