forked from OpenSourceArk/infomate.club
Docker, makefile and other bullshit
This commit is contained in:
parent
db94c13bc1
commit
d812a0628d
|
@ -30,6 +30,7 @@ pip-log.txt
|
|||
# Mac OS X
|
||||
.DS_Store
|
||||
|
||||
.mypy_cache
|
||||
private_settings.py
|
||||
local_settings.py
|
||||
media/images
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
FROM python:3.7
|
||||
|
||||
WORKDIR /app
|
||||
ARG requirements=requirements.txt
|
||||
|
||||
ADD . /app
|
||||
|
||||
RUN pip install --no-cache-dir -e .
|
||||
RUN pip install --no-cache-dir -r $requirements
|
|
@ -0,0 +1,37 @@
|
|||
PROJECT_NAME=infomate
|
||||
|
||||
all: run
|
||||
|
||||
# Install dev requirements
|
||||
dev-requirements:
|
||||
@pip3 install -r requirements.txt
|
||||
|
||||
# Migrate database to the latest version
|
||||
migrate:
|
||||
@python3 manage.py migrate
|
||||
|
||||
# Check types with mypy
|
||||
mypy:
|
||||
mypy $(PROJECT_NAME)
|
||||
|
||||
# Lint code with flake8
|
||||
lint:
|
||||
flake8 $(PROJECT_NAME)
|
||||
|
||||
# Runs dev server
|
||||
run:
|
||||
@python3 manage.py runserver
|
||||
|
||||
# Run dev server in docker
|
||||
docker_run:
|
||||
@python3 ./utils/wait_for_postgres.py
|
||||
@python3 manage.py migrate
|
||||
@python3 manage.py runserver
|
||||
|
||||
# Initialize feeds from boards.yml
|
||||
feed_init:
|
||||
@python3 ./scripts/initialize.py
|
||||
|
||||
# Refresh RSS feeds
|
||||
feed_refresh:
|
||||
@python3 ./scripts/update.py
|
|
@ -1,2 +1,9 @@
|
|||
# infomate.club
|
||||
|
||||
Experimental project
|
||||
|
||||
### Run
|
||||
|
||||
```
|
||||
$ docker-compose up
|
||||
```
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
version: '3.7'
|
||||
|
||||
services:
|
||||
infomate_app:
|
||||
build:
|
||||
context: .
|
||||
args:
|
||||
requirements: requirements.txt
|
||||
command: make docker_run
|
||||
container_name: infomate_app
|
||||
environment:
|
||||
- DEBUG=True
|
||||
- PYTHONUNBUFFERED=1
|
||||
restart: always
|
||||
volumes:
|
||||
- .:/app:delegated
|
||||
depends_on:
|
||||
- postgres
|
||||
ports:
|
||||
- "8000:8000"
|
||||
|
||||
postgres:
|
||||
image: postgres:11
|
||||
container_name: infomate_postgres
|
||||
environment:
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
- POSTGRES_DB=infomate
|
||||
ports:
|
||||
- 5432
|
|
@ -0,0 +1 @@
|
|||
__version__ = "0.1.0"
|
|
@ -50,8 +50,8 @@ DATABASES = {
|
|||
"ENGINE": "django.db.backends.postgresql_psycopg2",
|
||||
"NAME": "infomate",
|
||||
"USER": "postgres", # redefined in private_settings.py
|
||||
"PASSWORD": "",
|
||||
"HOST": "127.0.0.1",
|
||||
"PASSWORD": "postgres",
|
||||
"HOST": "postgres",
|
||||
"PORT": "5432",
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ SENTRY_DSN = None
|
|||
|
||||
try:
|
||||
# poor mans' private settings
|
||||
from .private_settings import *
|
||||
from infomate.private_settings import *
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
[mypy]
|
||||
ignore_missing_imports = True
|
||||
|
||||
check_untyped_defs = True
|
||||
disallow_any_generics = True
|
||||
disallow_untyped_defs = True
|
||||
follow_imports = silent
|
||||
strict_optional = True
|
||||
warn_redundant_casts = True
|
||||
warn_unused_ignores = True
|
|
@ -1,4 +1,5 @@
|
|||
Django==2.2.8
|
||||
psycopg2==2.8.3
|
||||
click==7.0
|
||||
awesome-slugify>=1.6.5
|
||||
requests==2.22.0
|
||||
|
@ -7,4 +8,5 @@ pyyaml==5.2
|
|||
feedparser==5.2.1
|
||||
sentry-sdk==0.13.5
|
||||
pyjwt==1.7.1
|
||||
nltk==3.4.4
|
||||
newspaper3k>=0.2.8
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
[flake8]
|
||||
max-line-length = 119
|
||||
exclude = etc static templates migrations
|
|
@ -0,0 +1,47 @@
|
|||
import os
|
||||
import re
|
||||
import pathlib
|
||||
from typing import List
|
||||
|
||||
from setuptools import find_packages, setup
|
||||
|
||||
REGEXP = re.compile(r'^__version__\W*=\W*"([\d.abrc]+)"')
|
||||
PARENT = pathlib.Path(__file__).parent
|
||||
|
||||
|
||||
def read_version():
|
||||
init_py = os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
"infomate",
|
||||
"__init__.py",
|
||||
)
|
||||
|
||||
with open(init_py) as f:
|
||||
for line in f:
|
||||
match = REGEXP.match(line)
|
||||
if match is not None:
|
||||
return match.group(1)
|
||||
else:
|
||||
msg = f"Cannot find version in ${init_py}"
|
||||
raise RuntimeError(msg)
|
||||
|
||||
|
||||
def read_requirements(path: str) -> List[str]:
|
||||
file_path = PARENT / path
|
||||
with open(file_path) as f:
|
||||
return f.read().split("\n")
|
||||
|
||||
|
||||
setup(
|
||||
name="infomate",
|
||||
version=read_version(),
|
||||
description="infomate",
|
||||
platforms=["POSIX"],
|
||||
packages=find_packages(),
|
||||
package_data={
|
||||
"": ["docs/*.*"]
|
||||
},
|
||||
include_package_data=True,
|
||||
install_requires=read_requirements("requirements.txt"),
|
||||
zip_safe=False,
|
||||
)
|
|
@ -59,8 +59,10 @@
|
|||
{% if article.image %}
|
||||
<img src="{{ article.image }}" alt="{{ article.title }}" class="article-tooltip-image">
|
||||
{% endif %}
|
||||
<span class="article-tooltip-title">{{ article.title|truncatechars:100 }}</span>
|
||||
{% if article.description and article.description|length > 20 %}
|
||||
|
||||
<span class="article-tooltip-title">{{ article.title|truncatechars:100 }}</span>
|
||||
|
||||
{% if article.description or article.summary %}
|
||||
<span class="article-tooltip-description">
|
||||
{% if article.summary %}
|
||||
{{ article.summary|striptags|nl2br|truncatechars:300|safe }}
|
||||
|
@ -69,6 +71,7 @@
|
|||
{% endif %}
|
||||
</span>
|
||||
{% endif %}
|
||||
|
||||
<span class="article-tooltip-info">{{ article.natural_created_at }}</span>
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
import socket
|
||||
import time
|
||||
import random
|
||||
|
||||
if __name__ == "__main__":
|
||||
while True:
|
||||
try:
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
||||
sock.connect(("postgres", 5432))
|
||||
print("Postgres had started")
|
||||
break
|
||||
except socket.error:
|
||||
print("Waiting for postgres")
|
||||
time.sleep(0.5 + (random.randint(0, 100) / 1000))
|
Loading…
Reference in New Issue