-
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.
Merge pull request #44 from CodeForAfrica/chore-optimize-image-build
Optimizing Python + Docker deploys using Pants
- Loading branch information
Showing
52 changed files
with
285 additions
and
156 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
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 +1,13 @@ | ||
# Commons API | ||
# COMMONS API | ||
|
||
## Applications | ||
|
||
| Name | Description | | ||
| ----------------------------------------------- | -------------------------------------------- | | ||
| [**TwoopsTracker**](./twoops_tracker/README.md) | A Twitter-based disinformation tracking tool | | ||
|
||
## Packages | ||
|
||
| Name | Description | | ||
| ---------------------------------- | -------------------------------------------------------------- | | ||
| [**`dj-cmd`**](./dj-cmd/README.md) | Command-line utility for running Django when bundled in `pex`. | |
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,3 @@ | ||
## `dj-cmd` | ||
|
||
Command-line utility for running Django & company entry point tasks when bundled in a single `pex` binary. |
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 |
---|---|---|
@@ -1 +1,6 @@ | ||
python_sources() | ||
|
||
pex_binary( | ||
name="cmd", | ||
entry_point="cmd.py", | ||
) |
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 |
---|---|---|
@@ -1 +1 @@ | ||
pants_requirements(name = "pants") | ||
pants_requirements(name="pants") |
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
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,27 +1,46 @@ | ||
# This is the exhaustive list of all environment variables used by | ||
# TwoopsTracker. If a variable is not declared here, docker-compose | ||
# will not pass it to the container at runtime. | ||
# | ||
# Do not assign values here. This *MUST* remain just a list. | ||
# Do not even do empty assignments e.g. | ||
# | ||
# TWOOPSTRACKER_DATABASE_URL= | ||
# | ||
# If you do the above, TWOOPSTRACKER_DATABASE_URL will be set to empty | ||
# string even when a different --env-file is passed to docker-compose | ||
|
||
# Required | ||
TWOOPSTRACKER_DATABASE_URL= | ||
TWOOPSTRACKER_SECRET_KEY= | ||
TWOOPSTRACKER_CONSUMER_KEY= | ||
TWOOPSTRACKER_CONSUMER_SECRET= | ||
TWOOPSTRACKER_ACCESS_TOKEN= | ||
TWOOPSTRACKER_ACCESS_TOKEN_SECRET= | ||
TWOOPTRACKER_STREAM_LISTENER_INTERVAL= | ||
TWOOPSTRACKER_ACCESS_TOKEN | ||
TWOOPSTRACKER_ACCESS_TOKEN_SECRET | ||
TWOOPSTRACKER_CELERY_BROKER_URL | ||
TWOOPSTRACKER_CONSUMER_KEY | ||
TWOOPSTRACKER_CONSUMER_SECRET | ||
TWOOPSTRACKER_DATABASE_URL | ||
TWOOPSTRACKER_GOOGLE_OAUTH2_CLIENT_ID | ||
TWOOPSTRACKER_GOOGLE_OAUTH2_CLIENT_SECRET | ||
TWOOPSTRACKER_SECRET_KEY | ||
TWOOPSTRACKER_STREAM_LISTENER_INTERVAL | ||
|
||
# End of Required | ||
|
||
# Optional | ||
TWOOPSTRACKER_ALLOWED_HOSTS= | ||
TWOOPSTRACKER_DEBUG=False | ||
TWOOPSTRACKER_CORS_ALLOWED_ORIGINS= | ||
TWOOPSTRACKER_SENTRY_DSN= | ||
TWOOPSTRACKER_EMAIL_CONFIRMATION_URL= | ||
TWOOPSTRACKER_PASSWORD_RESET_URL= | ||
ACCOUNT_EMAIL_VERIFICATION= | ||
SOCIALACCOUNT_EMAIL_VERIFICATION = | ||
LOGIN_URL= | ||
|
||
DEFAULT_FROM_EMAIL= | ||
EMAIL_USE_TLS= | ||
EMAIL_PORT= | ||
EMAIL_HOST_USER= | ||
EMAIL_HOST_PASSWORD= | ||
TWOOPSTRACKER_ACCOUNT_EMAIL_VERIFICATION | ||
TWOOPSTRACKER_ALLOWED_HOSTS | ||
TWOOPSTRACKER_BASE_DIR | ||
TWOOPSTRACKER_CORS_ALLOWED_ORIGINS | ||
TWOOPSTRACKER_DEBUG | ||
TWOOPSTRACKER_DEFAULT_FROM_EMAIL | ||
TWOOPSTRACKER_EMAIL_HOST_USER | ||
TWOOPSTRACKER_EMAIL_HOST_PASSWORD | ||
TWOOPSTRACKER_EMAIL_PORT | ||
TWOOPSTRACKER_EMAIL_USE_TLS | ||
TWOOPSTRACKER_EMAIL_CONFIRMATION_URL | ||
TWOOPSTRACKER_GUNICORN_EXTRA_CONFIG | ||
TWOOPSTRACKER_GUNICORN_LOG_LEVEL | ||
TWOOPSTRACKER_GUNICORN_TIMEOUT | ||
TWOOPSTRACKER_GUNICORN_WORKERS | ||
TWOOPSTRACKER_LOGIN_URL | ||
TWOOPSTRACKER_PASSWORD_RESET_URL | ||
TWOOPSTRACKER_SENTRY_DSN | ||
TWOOPSTRACKER_SOCIALACCOUNT_EMAIL_VERIFICATION |
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,50 @@ | ||
## TwoopsTracker | ||
|
||
A Twitter-based disinformation tracking tool built on a web-based dashboard that collects deleted tweet content from previously identified trolls and disinformation actors. The project seeks to help monitor the social posts of known disinfo actors. The primary tangible output of the project is to expose trolls behind toxic disinformation campaigns who routinely cover their tracks by deleting original inflammatory social media posts that sparked hate speech, disinformation campaigns or conspiracy theories. | ||
|
||
## Getting Started | ||
|
||
First create `.env` file in the app directory. From project root directory, | ||
|
||
```sh | ||
cp twoops_tracker/.env.template twoops_tracker/.env | ||
``` | ||
|
||
and modify the `.env` file according to your needs. | ||
|
||
## Build | ||
|
||
To build a pex binary, run: | ||
|
||
```sh | ||
./pants package twoops_tracker/py:twoopstracker | ||
``` | ||
|
||
To build the docker image, run: | ||
|
||
```sh | ||
VERSION=$(cat twoops_tracker/py/VERSION) ./pants package twoops_tracker/docker:twoopstracker | ||
``` | ||
|
||
## Run | ||
|
||
To run pex binary, execute: | ||
|
||
```sh | ||
./pants run twoops_tracker/py:twoopstracker | ||
``` | ||
|
||
To run the built docker image, execute: | ||
|
||
```sh | ||
docker-compose --env-file ./twoops_tracker/.env up twoopstracker | ||
``` | ||
|
||
**NOTE**: You may need to run `postres` container first to make sure database | ||
is ready to receive connections _before_ starting the `twoopstracker` app. | ||
|
||
To do so, run: | ||
|
||
```sh | ||
docker-compose --env-file ./twoops_tracker/.env up db | ||
``` |
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,3 @@ | ||
docker_image( | ||
name="docker", | ||
) |
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 +1 @@ | ||
FROM codeforafrica/twoopstracker:2.0.0a5 | ||
FROM codeforafrica/twoopstracker:2.0.0a6 |
Oops, something went wrong.