Public | Automated Build

Last pushed: 2 months ago
Short Description
Short description is empty for this repo.
Full Description




Local

All local development is done through docker.

All runtime options are chosen using environmental variables. The development
admin password is password and the username is username.

To fill the database with test data and setup static:

docker-compose up -d db
docker-compose run --rm web python manage.py init_db 0.0.0.0:8000 --init
docker-compose run --rm web python manage.py collectstatic --noinput

To start the development server:

docker-compose up
open http://localhost:8000

To run the tests:

docker-compose up -d db
docker-compose run --rm web python manage.py collectstatic --noinput
docker-compose run --rm -e CANADA_QUEUE_ASYNC=False web py.test
# or to run continiously use looponfail:
docker-compose run --rm -e CANADA_QUEUE_ASYNC=False web py.test -f

To make all migrations:

docker-compose run --rm web python manage.py makemigrations artists books custompages exhibitions photos press updates

To reset the local DB

docker-compose stop; docker-compose rm -f db data web worker; docker-compose up -d db; sleep 5; docker-compose run --rm web python manage.py init_db http://$(docker-machine ip default):8000/ --init; docker-compose run --rm web python manage.py collectstatic --noinput; docker-compose up web worker

Static

To recompute the static files:

docker-compose -f docker-compose.static.yml run --rm less
docker-compose -f docker-compose.static.yml run --rm sass

Produciton

To retransform all images:

heroku run python manage.py retransform artists.ArtistPhoto exhibitions.ExhibitionPhoto updates.UpdatePhoto

To clear cache

heroku run python manage.py clear_database_cache

Transfering

Database

To copy the DB from prod to staging:

heroku pg:copy canada::DATABASE_URL DATABASE_URL -a canada-development

And to copy to local environment:

docker-compose up -d db

bash -c 'env PATH=./bin/:$PATH dropdb postgres'

# don't worry that this will fail halfway through, just cant verify DB
bash -c 'env PATH=./bin/:$PATH heroku pg:pull DATABASE_URL postgres --app canada'

Configuration

Pulling

To then to run locally with env variables from production

heroku config:pull --overwrite --env docker-compose.env -a canada
echo 'CANADA_ALLOWED_HOST=*' >> docker-compose.env
docker-compose up web

Pushing

To push the app.json variables to an existing heroku app:

jq '.env | with_entries(select(.value | type == "string")) | to_entries | map("\(.key)=\(.value)") | join("\n")' -r app.json  > .env
heroku config:push --overwrite -a <app name>

Static

To replace the development static media assets (which are shared accross
all development apps) with the production ones:

heroku run python manage.py clone_bucket assets.canadanewyork.com assets-dev.canadanewyork.com -a canada-development

You can run that command anywhere you have set up S3 with the proper credentials
as the storage backend.

Docker Pull Command
Owner
saulshanabrook

Comments (0)