Skip to content

Commit

Permalink
Initial project scaffold
Browse files Browse the repository at this point in the history
Start this project off with a basic scaffolding for local development
using Poetry, Docker, and Tox. Bits and pieces have been cribbed from
past projects and many, many web searches.
  • Loading branch information
bd808 committed Sep 8, 2020
0 parents commit 7c56543
Show file tree
Hide file tree
Showing 17 changed files with 2,455 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*.py{cod}
*.egg-info
.cache
.gitignore
/.coverage
/.coverage.*
/.env
/.git
/.tox
/COPYING
/docker-compose.yaml
/docs
/poetry.toml
__pycache__
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.pyc
/*.egg-info/
/.coverage
/.env
/.python-version
/.tox
/docs/htmlcov
/poetry.toml
17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
default_language_version:
python: python3.7
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
- repo: https://github.com/PyCQA/bandit
rev: '1.6.2'
hooks:
- id: bandit
674 changes: 674 additions & 0 deletions COPYING

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM python:3.7-buster

ENV PYTHONBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
POETRY_ROOT="/srv/poetry" \
POETRY_BIN_DIR="/srv/poetry/bin" \
POETRY="/srv/poetry/bin/poetry" \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_CREATE=0

# Install poetry in an isolated venv
RUN python3 -m venv $POETRY_ROOT \
&& $POETRY_BIN_DIR/pip3 install poetry

WORKDIR /usr/src/app
COPY pyproject.toml poetry.lock ./
RUN $POETRY export -f requirements.txt -o requirements.txt \
&& pip3 install -r requirements.txt

COPY . ./
11 changes: 11 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
=================
Wikimedia Toolhub
=================

An authoritative and well promoted catalog of Wikimedia tools.

License
=======
Toolhub is licensed under the `GNU GPLv3+`_ license.

.. _GNU GPLv3+: https://www.gnu.org/copyleft/gpl.html
49 changes: 49 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
version: "3.2"
services:
toolhub:
build: .
image: "toolhub:${DOCKER_TOOLHUB_TAG}"
command: python3 manage.py runserver 0.0.0.0:8000
environment:
- DJANGO_SECRET_KEY
- DJANGO_DEBUG
- DJANGO_ALLOWED_HOSTS
- LOGGING_HANDLERS
- LOGGING_LEVEL
- DB_ENGINE
- DB_NAME
- DB_USER
- DB_PASSWORD
- DB_HOST
- DB_PORT
- CACHE_BACKEND
- CACHE_LOCATION
volumes:
- type: bind
source: .
target: /usr/src/app
consistency: cached
ports:
- "8000:8000"
restart: always
depends_on:
- db
db:
image: mariadb:10.4
restart: always
command:
- "--character-set-server=utf8mb4"
- "--collation-server=utf8mb4_unicode_ci"
environment:
MYSQL_DATABASE: ${DB_NAME}
MYSQL_USER: ${DB_USER}
MYSQL_PASSWORD: ${DB_PASSWORD}
MYSQL_ROOT_PASSWORD: ${DOCKER_DB_MYSQL_ROOT_PASSWORD}
volumes:
- type: volume
source: dbdata
target: /var/lib/mysql
consistency: consistent
volumes:
dbdata:
8 changes: 8 additions & 0 deletions docs/CODE_OF_CONDUCT.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
===============
Code of Conduct
===============

The development of this software is covered by the `Code of Conduct for
Wikimedia technical spaces`_.

.. _Code of Conduct for Wikimedia technical spaces: https://www.mediawiki.org/wiki/Code_of_Conduct
8 changes: 8 additions & 0 deletions docs/CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
=================
How to contribute
=================

.. code-block:: shell-session
$ docker-compose up --build -d
$ docker-compose run toolhub python3 manage.py migrate
21 changes: 21 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python3
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "toolhub.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == "__main__":
main()
Loading

0 comments on commit 7c56543

Please sign in to comment.