Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gitcoinco/web
Browse files Browse the repository at this point in the history
  • Loading branch information
owocki committed Apr 11, 2018
2 parents eda4629 + 2fec975 commit 16aa8e5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

.PHONY: help

PROJECT_DIR := $(subst -,, $(shell pwd | xargs basename))
CONTAINER_NAME := $(addsuffix _web_1, $(PROJECT_DIR))
WEB_CONTAINER_ID := $(shell docker inspect --format="{{.Id}}" $(CONTAINER_NAME))

compress-images: ## Compress and optimize images throughout the repository. Requires optipng, svgo, and jpeg-recompress.
@./scripts/compress_images.bash

Expand Down Expand Up @@ -46,5 +50,12 @@ compilemessages: ## Execute compilemessages for translations on the web containe
makemessages: ## Execute makemessages for translations on the web container.
@docker-compose exec web python3 app/manage.py makemessages

get_ipdb_shell: ## Drop into the active Django shell for inspection via ipdb.
@echo "Attaching to container: ($(CONTAINER_NAME)) - ($(WEB_CONTAINER_ID))"
@docker attach $(WEB_CONTAINER_ID)

get_django_shell: ## Open a standard Django shell.
@docker-compose exec web python3 app/manage.py shell

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ services:
depends_on:
- db
stdin_open: true
tty: true

testrpc:
image: trufflesuite/ganache-cli
Expand Down
11 changes: 8 additions & 3 deletions docs/RUNNING_LOCALLY_DOCKER.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,16 @@ GITHUB_CLIENT_SECRET=<COPY_FROM_GITHUB>

`Q: what's the best way to import ipdb; ipdb.set_trace() a HTTP request via docker?`

You need to run the web container with tty enabled and inspect the interactive shell.
Add `import ipdb;ipdb.set_trace()` to the method you want to inspect, you then run: `make get_ipdb_shell` to drop into the active shell for inspection.

Most people just start the stack normally, but run web outside of the standard flow. For instance, you'd want to run your service containers via something like `docker-compose up -d` then `docker-compose stop web; docker-compose run --service-ports web`
#### Access Django Shell

Details [here](https://github.com/docker/compose/issues/4677)
`Q: How can I access the Django shell, similar to: python manage.py shell ?`

Simply run: `make get_django_shell` or `docker-compose exec web python app/manage.py shell`

#### Access BASH

`Q: I want to inspect or manipulate the container via bash. How can I access the root shell of the container?`

Run: `docker-compose exec web bash`

0 comments on commit 16aa8e5

Please sign in to comment.