Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored to fix multiple issues. #48

Open
wants to merge 48 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
05946a1
Removed references to `django-box` from README.
ngnpope Dec 5, 2024
d60cafd
Removed obsolete configuration for Travis CI.
ngnpope Dec 5, 2024
fe49569
Removed obsolete configuration for Azure Pipelines.
ngnpope Dec 5, 2024
cc4dfaf
Removed obsolete script for pushing images to Docker Hub.
ngnpope Dec 5, 2024
ef7421b
Removed broken support for Oracle Database.
ngnpope Dec 5, 2024
7c9db3b
Removed obsolete version attribute from compose file.
ngnpope Dec 5, 2024
547e867
Removed obsolete `GEOIP_PATH` setting.
ngnpope Dec 5, 2024
0f61241
Removed unused `PIP_CACHE_VOLUME` environment variable.
ngnpope Dec 5, 2024
7015631
Renamed docker and compose files.
ngnpope Dec 5, 2024
8204a3c
Consolidated settings into a single file.
ngnpope Dec 5, 2024
407c210
Preferred "PostgreSQL" over "Postgres".
ngnpope Dec 5, 2024
deeeaf6
Grouped and reordered services in compose file.
ngnpope Dec 5, 2024
fc84c10
Removed obsolete entrypoint for MySQL.
ngnpope Dec 5, 2024
d97c54b
Extracted common compose configuration for services.
ngnpope Dec 5, 2024
66f9500
Enforced single instance for backend services.
ngnpope Dec 6, 2024
3cc6c64
Replaced `wait-for-it.sh` script with compose healthchecks.
ngnpope Dec 6, 2024
45e5732
Fixed indentation of compose file.
ngnpope Dec 6, 2024
c59c78f
Improved name of memcached services.
ngnpope Dec 6, 2024
756ca67
Fixed MySQL to use the same credentials as other databases.
ngnpope Dec 6, 2024
a3900b2
Fixed support for Selenium using Selenium Grid.
ngnpope Dec 6, 2024
a4111ef
Optimized services for testing.
ngnpope Dec 6, 2024
1c64296
Reinstated support for Oracle database.
ngnpope Dec 6, 2024
6dc210e
Added GIS support for MariaDB.
ngnpope Dec 6, 2024
42b9383
Added support for Redis cache backend.
ngnpope Dec 6, 2024
e3987c5
Added support for running Selenium with Edge.
ngnpope Dec 6, 2024
cad6848
Enabled cache backends for GIS tests.
ngnpope Dec 13, 2024
0cc9a8f
Created improved folder structure under `/django`.
ngnpope Dec 6, 2024
6466755
Extracted packages into separate files.
ngnpope Dec 6, 2024
d376c4f
Changed user name in container from `test` to `django`.
ngnpope Dec 6, 2024
a83b162
Modernized and optimized container file.
ngnpope Dec 6, 2024
6e6750a
Switched to `uv` for installing packages.
ngnpope Dec 6, 2024
072160c
Added a basic entrypoint script.
ngnpope Dec 6, 2024
6addaad
Added a `LICENSE` file.
ngnpope Dec 6, 2024
88ac278
Added some labels to the container image.
ngnpope Dec 6, 2024
6e377d4
Updated to use Debian Bookworm.
ngnpope Dec 6, 2024
2a36fa7
Added support for running with PyPy.
ngnpope Dec 6, 2024
34fedb7
Enforced color output when running in CI.
ngnpope Dec 6, 2024
fd6a73e
Updated `.editorconfig`.
ngnpope Dec 6, 2024
a731601
Replaced `flake8` with `pre-commit`.
ngnpope Dec 6, 2024
030c15d
Added linting tools and workflow for this repository.
ngnpope Dec 6, 2024
224942c
Added more entries to `.gitignore` file.
ngnpope Dec 7, 2024
2f3a8c1
Reordered entries in the `.env` file.
ngnpope Dec 7, 2024
2927b53
Updated the charset for MariaDB/MySQL.
ngnpope Dec 7, 2024
168aa91
Removed stale container image cache location.
ngnpope Dec 7, 2024
ca67e3b
Reworked commands for building documentation, etc.
ngnpope Dec 7, 2024
ea7b4a6
Bumped database versions to those supported on Django main.
ngnpope Dec 13, 2024
dd31887
Removed reference to `${PWD}` from `compose.yaml`.
ngnpope Dec 13, 2024
06aed4a
Reworked documentation in `README.md`.
ngnpope Dec 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .azure.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.git/
.dockerignore/
django
.dockerignore
output/
8 changes: 4 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
root = true

[*]
indent_style = space
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
charset = utf-8

[*.yml]
[*.{yaml,yml}]
indent_size = 2
9 changes: 5 additions & 4 deletions .env
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
PYTHON_IMPLEMENTATION=python
PYTHON_VERSION=3.10
POSTGRES_VERSION=13
POSTGIS_VERSION=3.0
MYSQL_VERSION=8
MARIADB_VERSION=10.5
PIP_CACHE_VOLUME=pip-cache
MYSQL_VERSION=8.0
ORACLE_VERSION=23.5.0.0
POSTGRESQL_VERSION=14
POSTGIS_VERSION=3.1
40 changes: 40 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
name: Lint

on: # yamllint disable-line rule:truthy
pull_request:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

env:
COLUMNS: '120'
FORCE_COLOR: '1'

jobs:
pre-commit:
runs-on: ubuntu-latest
name: pre-commit
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: pip
- name: Install packages
run: python -m pip install --upgrade pip pre-commit
- name: Run linting tools
run: pre-commit run --all-files
env:
PRE_COMMIT_COLOR: always
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
__pycache__/
.idea/
oracle/*.zip
.mypy_cache/
.ruff_cache/
5 changes: 5 additions & 0 deletions .hadolint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
ignored:
- DL3013 # Don't complain when upgrading to latest version of pip
- DL3022 # Due to use of additional_contexts in compose.yaml
- DL3042 # Caching is desired with RUN --mount=type=cache
53 changes: 53 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
ci:
autoupdate_schedule: weekly
repos:
- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
# - id: check-toml
- id: check-vcs-permalinks
- id: check-yaml
- id: debug-statements
- id: detect-private-key
- id: end-of-file-fixer
- id: file-contents-sorter
args: [--unique]
files: ^(?:packages|requirements)\.txt$
- id: fix-byte-order-marker
- id: fix-encoding-pragma
args: [--remove]
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.2
hooks:
- id: ruff
args: [--exit-non-zero-on-fix, --fix]
- id: ruff-format
args: [--check]
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
hooks:
- id: yamllint
args: [--strict]
- repo: https://github.com/hadolint/hadolint
rev: v2.12.0
hooks:
- id: hadolint-docker
name: hadolint
- repo: https://github.com/woodruffw/zizmor-pre-commit
rev: v0.9.2
hooks:
- id: zizmor
88 changes: 0 additions & 88 deletions .travis.yml

This file was deleted.

66 changes: 66 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# syntax=docker/dockerfile:1.12

ARG PYTHON_IMPLEMENTATION=python
ARG PYTHON_VERSION=3.10
FROM ${PYTHON_IMPLEMENTATION}:${PYTHON_VERSION}-slim-bookworm

LABEL org.opencontainers.image.authors="Django Software Foundation"
LABEL org.opencontainers.image.url="https://github.com/django/django-docker-box"
LABEL org.opencontainers.image.documentation="https://github.com/django/django-docker-box"
LABEL org.opencontainers.image.source="https://github.com/django/django-docker-box"
LABEL org.opencontainers.image.vendor="Django Software Foundation"
LABEL org.opencontainers.image.licenses="BSD-3-Clause"
LABEL org.opencontainers.image.title="Django Docker Box"
LABEL org.opencontainers.image.description="Container image for developing and testing Django."

SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-o", "xtrace", "-c"]

ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1

# Force colored output for various tooling in CI.
ENV COLUMNS=120
ENV FORCE_COLOR=1
ENV TERM="xterm-256color"

# Create user and prepare directories.
RUN <<EOF
useradd --home-dir=/django --no-create-home --no-log-init django
mkdir --parents /django/{.cache,output,source}
chown --recursive django:django /django
EOF

# Install system dependencies from package manager.
COPY --chown=django:django packages.txt /django/
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked <<EOF
rm --force /etc/apt/apt.conf.d/docker-clean
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
apt-get update --quiet --yes
xargs --arg-file=/django/packages.txt apt-get install --no-install-recommends --yes
EOF

# Install all Python requirements in a single command.
COPY --chown=django:django requirements.txt /django/requirements/extra.txt
COPY --chown=django:django --from=src tests/requirements/ /django/requirements/
COPY --chown=django:django --from=src docs/requirements.txt /django/requirements/docs.txt
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/
RUN --mount=type=cache,target=/root/.cache/uv <<EOF
cat /django/requirements/*.txt \
| grep --invert-match '^#' \
| sort --unique --version-sort \
| tee /django/requirements.txt
uv pip install --requirement=/django/requirements.txt --system
EOF

COPY --chown=django:django entrypoint.bash /django/

SHELL ["/bin/bash", "-c"]

ENV DJANGO_SETTINGS_MODULE=settings
ENV PYTHONPATH="${PYTHONPATH}:/django/source/"
USER django:django
VOLUME /django/output
VOLUME /django/source
WORKDIR /django/source/tests
ENTRYPOINT ["/django/entrypoint.bash"]
37 changes: 0 additions & 37 deletions Dockerfile

This file was deleted.

27 changes: 27 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) Django Software Foundation and individual contributors.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. Neither the name of Django nor the names of its contributors may be used
to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Loading
Loading