Files
rengine/Makefile
T
2c9e2503a9 Complete dev environment to debug/code easily (#1196)
* Add django debug toolbar

* Remove duplicate debug toolbar URLs

* Remove orphaned import in startScan

* Add DEBUG config commented in entrypoint

* Install debug toolbar into celery beat

* Create dev docker compose & entrypoints

* Move django toolbar install to dev entrypoints

* Install debug_toolbar only when debug env var is set

* Add dev command to MakeFile

* Use DEBUG from settings.py exclusively

* Add remote debug configuration in dev env

* Add VSCode debug configuration

* Celery log level to 1 when debug is on

* Remove hard coded celery debug port

* Add gunicorn in the production setup

* Add export var for celery log level

* Restrict debug port to 127.0.0.1

* Set remote debug to false by default

* Update doc on debug step for submitting issue

* Create dev docker compose & entrypoints

* Add django debug toolbar

* Remove duplicate debug toolbar URLs

* Remove orphaned import in startScan

* Add DEBUG config commented in entrypoint

* Install debug toolbar into celery beat

* Move django toolbar install to dev entrypoints

* Install debug_toolbar only when debug env var is set

* Add dev command to MakeFile

* Use DEBUG from settings.py exclusively

* Add remote debug configuration in dev env

* Add VSCode debug configuration

* Celery log level to 1 when debug is on

* Remove hard coded celery debug port

* Add gunicorn in the production setup

* Add export var for celery log level

* Restrict debug port to 127.0.0.1

* Set remote debug to false by default

* Update doc on debug step for submitting issue

---------

Co-authored-by: Raynald <raynald@easi-services.fr>
Co-authored-by: Psyray <psyray@users.noreply.github.com>
2024-03-18 10:33:16 +01:00

75 lines
2.9 KiB
Makefile

.DEFAULT_GOAL:=help
# Credits: https://github.com/sherifabdlnaby/elastdocker/
# This for future release of Compose that will use Docker Buildkit, which is much efficient.
COMPOSE_PREFIX_CMD := COMPOSE_DOCKER_CLI_BUILD=1
COMPOSE_ALL_FILES := -f docker-compose.yml
COMPOSE_DEV_ALL_FILES := -f docker-compose.dev.yml
SERVICES := db web proxy redis celery celery-beat
SERVICES_DEV := db web proxy redis celery celery-beat
# --------------------------
.PHONY: setup certs up build username pull down stop restart rm logs
certs: ## Generate certificates.
@${COMPOSE_PREFIX_CMD} docker-compose -f docker-compose.setup.yml run --rm certs
setup: ## Generate certificates.
@make certs
up: ## Build and start all services.
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} up -d --build ${SERVICES}
build: ## Build all services.
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} build ${SERVICES}
username: ## Generate Username (Use only after make up).
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} exec web python3 manage.py createsuperuser
pull: ## Pull Docker images.
docker login docker.pkg.github.com
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} pull
down: ## Down all services.
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} down
stop: ## Stop all services.
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} stop ${SERVICES}
restart: ## Restart all services.
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} restart ${SERVICES}
rm: ## Remove all services containers.
${COMPOSE_PREFIX_CMD} docker-compose $(COMPOSE_ALL_FILES) rm -f ${SERVICES}
test:
${COMPOSE_PREFIX_CMD} docker-compose $(COMPOSE_ALL_FILES) exec celery python3 -m unittest tests/test_scan.py
logs: ## Tail all logs with -n 1000.
${COMPOSE_PREFIX_CMD} docker-compose $(COMPOSE_ALL_FILES) logs --follow --tail=1000 ${SERVICES}
images: ## Show all Docker images.
${COMPOSE_PREFIX_CMD} docker-compose $(COMPOSE_ALL_FILES) images ${SERVICES}
prune: ## Remove containers and delete volume data.
@make stop && make rm && docker volume prune -f
help: ## Show this help.
@echo "Make application docker images and manage containers using docker-compose files."
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m (default: help)\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-12s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
dev_build: ## Build all services.
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_DEV_ALL_FILES} build ${SERVICES_DEV}
dev_up: ## Build and start all services.
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_DEV_ALL_FILES} up -d --build ${SERVICES_DEV}
dev_down: ## Down all services.
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_DEV_ALL_FILES} down
dev_logs: ## Tail all logs with -n 1000.
${COMPOSE_PREFIX_CMD} docker-compose $(COMPOSE_DEV_ALL_FILES) logs --follow --tail=1000 ${SERVICES_DEV}