Skip to content

Commit

Permalink
fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
xmnlab committed Feb 19, 2024
1 parent 5b0e5d2 commit 381f7bf
Show file tree
Hide file tree
Showing 117 changed files with 6,078 additions and 966 deletions.
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.editorconfig
.gitattributes
.github
.gitignore
.gitlab-ci.yml
.idea
.pre-commit-config.yaml
.readthedocs.yml
.travis.yml
venv
.git
.envs/
4 changes: 4 additions & 0 deletions .envs/.local/.django
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# General
# ------------------------------------------------------------------------------
USE_DOCKER=yes
IPYTHONDIR=/app/.ipython
7 changes: 7 additions & 0 deletions .envs/.local/.postgres
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# PostgreSQL
# ------------------------------------------------------------------------------
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
POSTGRES_DB=feedback_linker
POSTGRES_USER=debug
POSTGRES_PASSWORD=debug
34 changes: 34 additions & 0 deletions .envs/.production/.django
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# General
# ------------------------------------------------------------------------------
# DJANGO_READ_DOT_ENV_FILE=True
DJANGO_SETTINGS_MODULE=config.settings.production
DJANGO_SECRET_KEY=rzB5Sl2LAHyQOR5SAKqc0KeJTyUjNYVhd0ovG6H1dGrdvpd2FtZ9phEacFvFcbd0
DJANGO_ADMIN_URL=Rz4fpz5g02YMT9VXPQ4QMu8J3hoXOIBa/
DJANGO_ALLOWED_HOSTS=.https://opensciencelabs.github.io/feedback-linker

# Security
# ------------------------------------------------------------------------------
# TIP: better off using DNS, however, redirect is OK too
DJANGO_SECURE_SSL_REDIRECT=False

# Email
# ------------------------------------------------------------------------------
DJANGO_SERVER_EMAIL=


# django-allauth
# ------------------------------------------------------------------------------
DJANGO_ACCOUNT_ALLOW_REGISTRATION=True

# Gunicorn
# ------------------------------------------------------------------------------
WEB_CONCURRENCY=4

# Sentry
# ------------------------------------------------------------------------------
SENTRY_DSN=


# Redis
# ------------------------------------------------------------------------------
REDIS_URL=redis://redis:6379/0
7 changes: 7 additions & 0 deletions .envs/.production/.postgres
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# PostgreSQL
# ------------------------------------------------------------------------------
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
POSTGRES_DB=feedback_linker
POSTGRES_USER=debug
POSTGRES_PASSWORD=debug
52 changes: 34 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,25 @@ default_stages:
- commit
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-json
- id: check-toml
- id: check-xml
# - id: check-yaml
- id: debug-statements
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: detect-private-key

- repo: https://github.com/Riverside-Healthcare/djLint
rev: v1.34.1
hooks:
- id: djlint-reformat-django
- id: djlint-django

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.2"
Expand Down Expand Up @@ -34,24 +50,24 @@ repos:
types:
- python

- id: mypy
name: mypy
entry: mypy .
language: system
pass_filenames: false
# - id: mypy
# name: mypy
# entry: mypy .
# language: system
# pass_filenames: false

- id: shellcheck
name: shellcheck
entry: shellcheck
language: system
types_or:
- sh
- shell
- ash
- bash
- bats
- dash
- ksh
# - id: shellcheck
# name: shellcheck
# entry: shellcheck
# language: system
# types_or:
# - sh
# - shell
# - ash
# - bash
# - bats
# - dash
# - ksh

- id: bandit
name: bandit
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.makim.yaml
docs/changelog.md
*.html
51 changes: 51 additions & 0 deletions containers/compose.local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
version: "3"

volumes:
feedback_linker_local_postgres_data: {}
feedback_linker_local_postgres_data_backups: {}

services:
django:
build:
context: .
dockerfile: ./compose/local/django/Dockerfile
image: feedback_linker_local_django
container_name: feedback_linker_local_django
depends_on:
- postgres
volumes:
- .:/app:z
env_file:
- ./.envs/.local/.django
- ./.envs/.local/.postgres
ports:
- "8000:8000"
command: /start

postgres:
build:
context: .
dockerfile: ./compose/production/postgres/Dockerfile
image: feedback_linker_production_postgres
container_name: feedback_linker_local_postgres
volumes:
- feedback_linker_local_postgres_data:/var/lib/postgresql/data
- feedback_linker_local_postgres_data_backups:/backups
env_file:
- ./.envs/.local/.postgres

docs:
image: feedback_linker_local_docs
container_name: feedback_linker_local_docs
build:
context: .
dockerfile: ./compose/local/docs/Dockerfile
env_file:
- ./.envs/.local/.django
volumes:
- ./docs:/docs:z
- ./config:/app/config:z
- ./feedback_linker:/app/feedback_linker:z
ports:
- "9000:9000"
command: /start-docs
61 changes: 61 additions & 0 deletions containers/compose.production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
version: "3"

volumes:
production_postgres_data: {}
production_postgres_data_backups: {}
production_traefik: {}
production_django_media: {}

services:
django:
build:
context: .
dockerfile: ./compose/production/django/Dockerfile

image: feedback_linker_production_django
volumes:
- production_django_media:/app/feedback_linker/media
depends_on:
- postgres
- redis
env_file:
- ./.envs/.production/.django
- ./.envs/.production/.postgres
command: /start

postgres:
build:
context: .
dockerfile: ./compose/production/postgres/Dockerfile
image: feedback_linker_production_postgres
volumes:
- production_postgres_data:/var/lib/postgresql/data
- production_postgres_data_backups:/backups
env_file:
- ./.envs/.production/.postgres

traefik:
build:
context: .
dockerfile: ./compose/production/traefik/Dockerfile
image: feedback_linker_production_traefik
depends_on:
- django
volumes:
- production_traefik:/etc/traefik/acme
ports:
- "0.0.0.0:80:80"
- "0.0.0.0:443:443"

redis:
image: docker.io/redis:6

nginx:
build:
context: .
dockerfile: ./compose/production/nginx/Dockerfile
image: feedback_linker_local_nginx
depends_on:
- django
volumes:
- production_django_media:/usr/share/nginx/media:ro
82 changes: 82 additions & 0 deletions containers/django/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@

# define an alias for the specific python version used in this file.
FROM docker.io/python:3.11.8-slim-bookworm as python

# Python build stage
FROM docker.io/python as python-build-stage

ARG BUILD_ENVIRONMENT=production

# Install apt packages
RUN apt-get update && apt-get install --no-install-recommends -y \
# dependencies for building Python packages
build-essential \
# psycopg2 dependencies
libpq-dev

# Requirements are installed here to ensure they will be cached.
COPY ./requirements .

# Create Python Dependency and Sub-Dependency Wheels.
RUN pip wheel --wheel-dir /usr/src/app/wheels \
-r ${BUILD_ENVIRONMENT}.txt


# Python 'run' stage
FROM docker.io/python as python-run-stage

ARG BUILD_ENVIRONMENT=production
ARG APP_HOME=/app

ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV BUILD_ENV ${BUILD_ENVIRONMENT}

WORKDIR ${APP_HOME}

RUN addgroup --system django \
&& adduser --system --ingroup django django


# Install required system dependencies
RUN apt-get update && apt-get install --no-install-recommends -y \
# psycopg2 dependencies
libpq-dev \
# Translations dependencies
gettext \
# cleaning up unused files
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*

# All absolute dir copies ignore workdir instruction. All relative dir copies are wrt to the workdir instruction
# copy python dependency wheels from python-build-stage
COPY --from=python-build-stage /usr/src/app/wheels /wheels/

# use wheels to install python dependencies
RUN pip install --no-cache-dir --no-index --find-links=/wheels/ /wheels/* \
&& rm -rf /wheels/


COPY --chown=django:django ./compose/production/django/entrypoint /entrypoint
RUN sed -i 's/\r$//g' /entrypoint
RUN chmod +x /entrypoint


COPY --chown=django:django ./compose/production/django/start /start
RUN sed -i 's/\r$//g' /start
RUN chmod +x /start


# copy application code to WORKDIR
COPY --chown=django:django . ${APP_HOME}

# make django owner of the WORKDIR directory as well.
RUN chown django:django ${APP_HOME}

USER django

RUN DATABASE_URL="" \
DJANGO_SETTINGS_MODULE="config.settings.test" \
python manage.py compilemessages

ENTRYPOINT ["/entrypoint"]
Loading

0 comments on commit 381f7bf

Please sign in to comment.