diff --git a/.gitignore b/.gitignore index c815dc2..b809595 100644 --- a/.gitignore +++ b/.gitignore @@ -140,3 +140,6 @@ GitHub.sublime-settings *.my_pgpass *.sql artel/static/ + +# media +artel/media/* diff --git a/artel/.pre-commit-config.yaml b/artel/.pre-commit-config.yaml new file mode 100644 index 0000000..79c24de --- /dev/null +++ b/artel/.pre-commit-config.yaml @@ -0,0 +1,22 @@ +repos: +- repo: https://github.com/psf/black + rev: 21.9b0 + hooks: + - id: black + args: [--safe] + +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - id: debug-statements + language_version: python3 + +- repo: https://github.com/PyCQA/flake8 + rev: 3.9.2 + hooks: + - id: flake8 + language_version: python3 diff --git a/artel/Dockerfile b/artel/Dockerfile index a8b15d3..a8ed9a6 100644 --- a/artel/Dockerfile +++ b/artel/Dockerfile @@ -57,4 +57,4 @@ RUN python manage.py collectstatic --noinput --clear # PRACTICE. The database should be migrated manually or using the release # phase facilities of your hosting platform. This is used only so the # Wagtail instance can be started with a simple "docker run" command. -CMD set -xe; python manage.py migrate --noinput; gunicorn artel.wsgi:application +CMD set -xe; python manage.py migrate --noinput; gunicorn --bind=0.0.0.0:8000 artel.wsgi:application diff --git a/artel/artel/settings/base.py b/artel/artel/settings/base.py index 15ea9df..49a7f4a 100644 --- a/artel/artel/settings/base.py +++ b/artel/artel/settings/base.py @@ -93,7 +93,7 @@ import dj_database_url as db_url DATABASES = { "default": db_url.parse( - "postgres://comfy:password@db/comfy_shop" + os.environ.get("DATABASE_URL", "postgres://comfy:password@db/comfy_shop") ) } diff --git a/artel/artel/settings/production.py b/artel/artel/settings/production.py index 9ca4ed7..f885e60 100644 --- a/artel/artel/settings/production.py +++ b/artel/artel/settings/production.py @@ -2,7 +2,15 @@ from .base import * DEBUG = False -try: - from .local import * -except ImportError: - pass +SECRET_KEY = os.environ.get("SECRET_KEY") +ALLOWED_HOSTS = [ + "localhost", + "0.0.0.0", + "127.0.0.1", + "artel.tepewu.pl" +] +CSRF_TRUSTED_ORIGINS = [ + "https://0.0.0.0", "http://0.0.0.0", + "https://localhost", "http://localhost", + "https://artel.tepewu.pl" +] diff --git a/artel/docker-compose-prod.yml b/artel/docker-compose-prod.yml index 70646be..23a0c08 100644 --- a/artel/docker-compose-prod.yml +++ b/artel/docker-compose-prod.yml @@ -1,20 +1,55 @@ version: "3.8" services: - comfy: - build: - dockerfile: Dockerfile - context: ./ - ports: - - "8000:8000" - volumes: - - ./:/app + db: image: postgres restart: always environment: - POSTGRES_ROOT_PASSWORD: password - POSTGRES_USER: comfy - POSTGRES_PASSWORD: password - POSTGRES_DB: comfy_shop + - POSTGRES_ROOT_PASSWORD + - POSTGRES_USER + - POSTGRES_PASSWORD + - POSTGRES_DB volumes: - ../postgres/:/var/lib/postgresql + env_file: + - .env + networks: + - nginx_network + + comfy: + build: + dockerfile: Dockerfile + context: ./ + restart: always + ports: + - "8001:8000" + volumes: + - ./:/app + environment: + - SECRET_KEY + - DATABASE_URL + - DJANGO_SETTINGS_MODULE + env_file: + - .env + depends_on: + - db + networks: + - nginx_network + + web: + image: nginx + volumes: + - ../nginx/conf.d/:/etc/nginx/conf.d/ + - ./static/:/opt/services/comfy/static + - ./media/:/opt/services/comfy/media + ports: + - "8000:80" + environment: + - NGINX_HOST=artel.tepewu.pl + - NGINX_PORT=80 + networks: + - nginx_network + +networks: + nginx_network: + driver: bridge diff --git a/artel/docker-compose.yml b/artel/docker-compose.yml index 94c441f..7c7d896 100644 --- a/artel/docker-compose.yml +++ b/artel/docker-compose.yml @@ -8,13 +8,20 @@ services: - "8000:8000" volumes: - ./:/app + environment: + - SECRET_KEY + - DATABASE_URL + env_file: + - .env db: image: postgres restart: always environment: - POSTGRES_ROOT_PASSWORD: password - POSTGRES_USER: comfy - POSTGRES_PASSWORD: password - POSTGRES_DB: comfy_shop + - POSTGRES_ROOT_PASSWORD + - POSTGRES_USER + - POSTGRES_PASSWORD + - POSTGRES_DB volumes: - ../postgres/:/var/lib/postgresql + env_file: + - .env diff --git a/artel/media/images/16_cospito.2e16d0ba.fill-320x240.jpg b/artel/media/images/16_cospito.2e16d0ba.fill-320x240.jpg deleted file mode 100644 index 4e33f71..0000000 Binary files a/artel/media/images/16_cospito.2e16d0ba.fill-320x240.jpg and /dev/null differ diff --git a/artel/media/images/16_cospito.2e16d0ba.fill-640x480.jpg b/artel/media/images/16_cospito.2e16d0ba.fill-640x480.jpg deleted file mode 100644 index cf3e55b..0000000 Binary files a/artel/media/images/16_cospito.2e16d0ba.fill-640x480.jpg and /dev/null differ diff --git a/artel/media/images/16_cospito.max-165x165.jpg b/artel/media/images/16_cospito.max-165x165.jpg deleted file mode 100644 index b38f23f..0000000 Binary files a/artel/media/images/16_cospito.max-165x165.jpg and /dev/null differ diff --git a/artel/media/images/16_cospito.max-320x200.jpg b/artel/media/images/16_cospito.max-320x200.jpg deleted file mode 100644 index c4231dc..0000000 Binary files a/artel/media/images/16_cospito.max-320x200.jpg and /dev/null differ diff --git a/artel/media/images/339373445_163932656580560_748707215925272875.max-165x165.jpg b/artel/media/images/339373445_163932656580560_748707215925272875.max-165x165.jpg deleted file mode 100644 index e2443fd..0000000 Binary files a/artel/media/images/339373445_163932656580560_748707215925272875.max-165x165.jpg and /dev/null differ diff --git a/artel/media/original_images/16_cospito.jpg b/artel/media/original_images/16_cospito.jpg deleted file mode 100644 index bb98aeb..0000000 Binary files a/artel/media/original_images/16_cospito.jpg and /dev/null differ diff --git a/artel/media/original_images/339373445_163932656580560_7487072159252728756_n.jpg b/artel/media/original_images/339373445_163932656580560_7487072159252728756_n.jpg deleted file mode 100644 index 6287cbc..0000000 Binary files a/artel/media/original_images/339373445_163932656580560_7487072159252728756_n.jpg and /dev/null differ diff --git a/artel/pyproject.toml b/artel/pyproject.toml new file mode 100644 index 0000000..03cc4cf --- /dev/null +++ b/artel/pyproject.toml @@ -0,0 +1,9 @@ +[tool.flake8] +max-line-length = 120 + +[tool.black] +line-length = 119 + +[tool.isort] +profile = "black" +multi_line_output = 3 diff --git a/artel/requirements_dev.txt b/artel/requirements_dev.txt new file mode 100644 index 0000000..54eda76 --- /dev/null +++ b/artel/requirements_dev.txt @@ -0,0 +1,4 @@ +FLAKE8>=6.0.0 +pre-commit>=3.3.1 +isort>=5.12 +black>=23.3.0 diff --git a/artel/uwsgi.ini b/artel/uwsgi.ini new file mode 100644 index 0000000..1a182d5 --- /dev/null +++ b/artel/uwsgi.ini @@ -0,0 +1,14 @@ +[uwsgi] +project = artel +base = artel/ +socket_dir = %(base) + +chdir = %(base) +module = %(project).wsgi:application + +master = true +processes = 5 + +socket = %(socket_dir)/%(project).sock +vacuum = true +daemonize = /var/log/uwsgi/project.log \ No newline at end of file