Skip to content

Commit 16aa8e5

Browse files
committed
Merge branch 'master' of github.com:gitcoinco/web
2 parents eda4629 + 2fec975 commit 16aa8e5

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
.PHONY: help
55

6+
PROJECT_DIR := $(subst -,, $(shell pwd | xargs basename))
7+
CONTAINER_NAME := $(addsuffix _web_1, $(PROJECT_DIR))
8+
WEB_CONTAINER_ID := $(shell docker inspect --format="{{.Id}}" $(CONTAINER_NAME))
9+
610
compress-images: ## Compress and optimize images throughout the repository. Requires optipng, svgo, and jpeg-recompress.
711
@./scripts/compress_images.bash
812

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

53+
get_ipdb_shell: ## Drop into the active Django shell for inspection via ipdb.
54+
@echo "Attaching to container: ($(CONTAINER_NAME)) - ($(WEB_CONTAINER_ID))"
55+
@docker attach $(WEB_CONTAINER_ID)
56+
57+
get_django_shell: ## Open a standard Django shell.
58+
@docker-compose exec web python3 app/manage.py shell
59+
4960
help:
5061
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ services:
3939
depends_on:
4040
- db
4141
stdin_open: true
42+
tty: true
4243

4344
testrpc:
4445
image: trufflesuite/ganache-cli

docs/RUNNING_LOCALLY_DOCKER.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,16 @@ GITHUB_CLIENT_SECRET=<COPY_FROM_GITHUB>
133133

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

136-
You need to run the web container with tty enabled and inspect the interactive shell.
136+
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.
137137

138-
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`
138+
#### Access Django Shell
139139

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

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

144+
#### Access BASH
143145

146+
`Q: I want to inspect or manipulate the container via bash. How can I access the root shell of the container?`
147+
148+
Run: `docker-compose exec web bash`

0 commit comments

Comments
 (0)