From 75a90827d9591dd70f0ac46a1d7e0680a5b628e6 Mon Sep 17 00:00:00 2001 From: Steve Stein Date: Thu, 12 May 2022 03:21:47 -0600 Subject: [PATCH] Add makefile for docker commands (#43) * Create makefile * Update readme with makefile commands * Update readme spacing and sh comments * Add back line that was taken out in readme * stop and down rename in makefile * Updates as per feedback * Update readme to include raw docker commands as well as makefile ones --- Makefile | 44 +++++++++++++++++++++++++ README.md | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0752257 --- /dev/null +++ b/Makefile @@ -0,0 +1,44 @@ +.PHONY: help +.DEFAULT_GOAL := help + +help: ## ⁉️ - Display help comments for each make command + @grep -E '^[0-9a-zA-Z_-]+:.*? .*$$' \ + $(MAKEFILE_LIST) \ + | awk 'BEGIN { FS=":.*?## " }; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' \ + | sort + +build: ## Build the backend Docker image + docker-compose build web + +start: ## Bring the backend Docker container up + docker-compose up + +stop: ## Stop the backend Docker container + docker-compose stop + +ssh: ## Enter the running backend Docker container for the wagtail bakery site + docker-compose exec web bash + +ssh-shell: ## Enter the running Docker container shell + docker-compose exec web python manage.py shell + +ssh-fe: ## Open a shell to work with the frontend code (Node/NPM) + docker-compose exec frontend bash + +ssh-wagtail: ## Enter the running Docker container for the wagtail development environment + docker-compose exec -w /code/wagtail web bash + +ssh-db: ## Open a PostgreSQL shell session + docker-compose exec web python manage.py dbshell + +down: ## Stop and remove all Docker containers + docker-compose down + +migrations: ## Make migrations to the wagtail bakery site + docker-compose exec web python manage.py makemigrations + +migrate: ## Migrate the wagtail bakery site migrations + docker-compose exec web python manage.py migrate + +test: ## Run all wagtail tests or pass in a file with `make test file=wagtail.admin.tests.test_name.py` + docker-compose exec -w /code/wagtail web python runtests.py $(FILE) diff --git a/README.md b/README.md index f9c2feb..8a7c137 100644 --- a/README.md +++ b/README.md @@ -86,36 +86,133 @@ frontend docker-entrypoint.sh /bin/ ... Up web ./manage.py runserver 0.0. ... Up 0.0.0.0:8000->8000/tcp ``` +### Build the backend Docker image +```sh +make build +``` +or +```sh +docker-compose build web +``` + +### Bring the backend Docker container up + +```sh +make start +``` +or +```sh +docker-compose up +``` + +### Stop all Docker containers + +```sh +make stop +``` +or +```sh +docker-compose stop +``` +### Stop all and remove all Docker containers + +```sh +make down +``` +or +```sh +docker-compose down +``` + ### Run tests +```sh +make test +``` +or ```sh docker-compose exec -w /code/wagtail web python runtests.py ``` +### Run tests for a specific file + +```sh +make test file=wagtail.admin.tests.test_name.py +``` +or +```sh +docker-compose exec -w /code/wagtail web python runtests.py wagtail.admin.tests.{test_file_name_here}.py +``` + ### Open a Django shell session +```sh +make ssh-shell +``` +or ```sh docker-compose exec web python manage.py shell ``` ### Open a PostgreSQL shell session +```sh +make ssh-db +``` +or ```sh docker-compose exec web python manage.py dbshell ``` - ### Open a shell on the web server +```sh +make ssh +``` +or ```sh docker-compose exec web bash ``` ### Open a shell to work with the frontend code (Node/NPM) +```sh +make ssh-fe +``` +or ```sh docker-compose exec frontend bash ``` +### Open a shell to work within the wagtail container + +```sh +make ssh-fe +``` +or +```sh +docker-compose exec -w /code/wagtail web bash +``` + +### Make migrations to the wagtail bakery site + +```sh +make migrations +``` +or +```sh +docker-compose exec web python manage.py makemigrations +``` + +### Migrate the wagtail bakery site + +```sh +make migrate +``` +or +```sh +docker-compose exec web python manage.py migrate +``` + Getting ready to contribute ---------------------------