-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
124 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
FROM python:3.8 | ||
|
||
WORKDIR /src/ | ||
|
||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
RUN mkdir media static logs | ||
VOLUME ["/src/logs"] | ||
|
||
RUN apt-get update | ||
RUN apt-get install -y libpq-dev gcc python-dev | ||
|
||
RUN pip install --upgrade pip | ||
RUN pip install setuptools | ||
COPY ./requirements.txt /src/requirements.txt | ||
RUN pip install -r requirements.txt | ||
|
||
|
||
COPY . /src/ | ||
COPY ./start.sh /start.sh | ||
COPY ./entrypoint.sh /entrypoint.sh | ||
|
||
RUN chmod +x /entrypoint.sh | ||
RUN chmod +x /start.sh | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] | ||
CMD ["/start.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,26 @@ | ||
# DebunkBot | ||
A bot that debunks claims shared on social media by sharing a fact check. Powered by Google Sheets and the rains in Africa. Accessible at https://debunkbot.codeforafrica.org/ | ||
|
||
## Development | ||
|
||
Gitignore is standardized for this project using [gitignore.io](https://www.gitignore.io/) to support various development platforms. | ||
To get the project up and running: | ||
|
||
- Clone this repo | ||
|
||
### Virtual environment | ||
|
||
- Use virtualenv to create your virtual environment; `virtualenv venv` | ||
- Activate the virtual environment; `source venv/bin/activate` | ||
- Install the requirements; `pip install -r requirements.txt` | ||
- Create a debunkbot database | ||
- Add database connection details to `.env` file, using `.env.sample` as a template | ||
- Migrate the database: `python manage.py migrate` | ||
- Run the server: `python manage.py runserver` | ||
|
||
### Docker | ||
|
||
Using docker compose: | ||
|
||
- Build the project; `docker-compose build` | ||
- Run the project; `docker-compose up -d` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
version: '3.3' | ||
|
||
services: | ||
db: | ||
image: "postgres:12" | ||
hostname: postgres | ||
volumes: | ||
- postgres_data:/var/lib/postgresql/data/ | ||
environment: | ||
- POSTGRES_USER=debunkbot | ||
- POSTGRES_PASSWORD=debunkbot | ||
- POSTGRES_DB=debunkbot | ||
web: | ||
build: | ||
context: . | ||
volumes: | ||
- ./:/src | ||
ports: | ||
- 8000:8000 | ||
env_file: | ||
- ./.env | ||
depends_on: | ||
- db | ||
|
||
volumes: | ||
postgres_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/sh | ||
|
||
if [ "$DATABASE" = "postgres" ] | ||
then | ||
echo "Waiting for postgres..." | ||
|
||
while ! nc -z $SQL_HOST $SQL_PORT; do | ||
sleep 0.1 | ||
done | ||
|
||
echo "PostgreSQL started" | ||
fi | ||
|
||
python manage.py flush --no-input | ||
python manage.py migrate | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/sh | ||
python manage.py migrate --noinput # Apply database migrations | ||
python manage.py collectstatic --clear --noinput # Collect static files | ||
|
||
# Prepare log files and start outputting logs to stdout | ||
touch /src/logs/gunicorn.log | ||
touch /src/logs/access.log | ||
tail -n 0 -f /src/logs/*.log & | ||
|
||
# Start Gunicorn processes | ||
echo Starting Gunicorn. | ||
exec gunicorn \ | ||
--bind 0.0.0.0:8000 \ | ||
--workers 3 \ | ||
--worker-class gevent \ | ||
--log-level=info \ | ||
--log-file=/src/logs/gunicorn.log \ | ||
--access-logfile=/src/logs/access.log \ | ||
--name debunkbot --reload debunkbot.wsgi:application \ | ||
--chdir debunkbot/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters