GithubHelp home page GithubHelp logo

isabella232 / crowdsourcing Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nypublicradio/crowdsourcing

0.0 0.0 0.0 118 KB

crowdsourcing microservice

Python 83.71% HTML 5.81% Shell 10.23% Dockerfile 0.25%

crowdsourcing's Introduction

NYPR Crowdsourcing

Development

Prerequisites

You will need the following software properly installed on your computer. Please follow all the directions as written on the websites of these projects and do not neglect to install their dependencies.

Getting started

Clone the repo.

$ git clone [email protected]:nypublicradio/crowdsourcing
$ cd crowdsourcing

Create an .env file for environment variables

$ cp .env.sample .env

Build the image.

$ docker-compose build

Run the development server.

$ docker-compose up

Run the migrations.

$ docker-compose exec django manage.py migrate

Create a superuser.

$ docker-compose exec django manage.py createsuperuser

Running tests

Tests are executed via pytest using NYPR's setuptools extensions. Use exec to run tests on running development containers and run to run tests within a new container.

$ docker-compose exec django python setup.py test

For faster testing in development, test dependencies can be permanently installed.

$ docker-compose exec django python setup.py test_requirements

Interactive debugging

To enable ipdb breakpoints developers need to attach to the Docker container running the Django development server.

Start the containers and detach from the log output.

$ docker-compose up -d

If using ipdb for debugging it will need to be installed in the development container.

$ docker-compose exec django pip install ipdb

Attach to the container. The example below provides the likely name for the Django container, but if incorrect it can be obtained via docker-compose ps.

$ docker attach crowdsourcing_django_1

Alternate workflow

For developers who prefer to run the Django server directly on their local system an alternate workflow is available.

Create and activate a virtual environment.

$ virtualenv ~/.virtualenvs/crowdsourcing
$ . ~/.virtualenvs/crowdsourcing/bin/activate

Install the package dependencies and (optionally) the test dependencies.

$ pip install -e .
$ python setup.py test_requirements

Start a Postgres container in the background. This will expose Postgres on localhost port 5432. Exclude the -v ... argument to avoid persisting data over multiple container runs.

$ docker run -v /tmp/postgres:/var/lib/postgresql/data -dp 5432:5432 postgres

Set environment variables to target postgres container. The four commands below and any other development config can be added to the virtual environment's bin/activate script to automate this moving forward.

$ export DB_HOST=localhost
$ export DB_NAME=postgres
$ export DB_USER=postgres
$ export DB_PASSWORD=

Execute the Django initialization commands.

$ ./manage.py migrate
$ ./manage.py createsuperuser
$ ./manage.py runserver 0.0.0.0:8080

Configuration

Configuration should be set via environment variables.

Config Value Description
AWS_ACCESS_KEY_ID Set via boto3 config or environment variable.
AWS_DEFAULT_REGION Set via boto3 config or environment variable.
AWS_SECRET_ACCESS_KEY Set via boto3 config or environment variable.
AWS_S3_CUSTOM_DOMAIN Cloudfront domain alias for static files.
AWS_STORAGE_BUCKET_NAME S3 bucket for Django's storage backend.
DB_HOST IP or hostname of the database.
DB_NAME Database name (for app, not tests).
DB_PASSWORD Database password (for app, not tests).
DB_USER Database user (for app, not tests).
DJANGO_URL_PREFIX URL route to service (/crowdsourcing in prod).
DJANGO_SECRET_KEY Securely generated key for internal Django use.
SENTRY_DSN URL for reporting uncaught exceptions.

crowdsourcing's People

Contributors

bryn19 avatar dependabot[bot] avatar jwdashel avatar kedmundson avatar mattoberle avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.