UID := $(shell id -u) GID := $(shell id -g) export UID export GID .PHONY: help_redirect help_redirect: @$(MAKE) help --no-print-directory .PHONY: help_submake help_submake: @echo "Host only commands:" @grep -E '^[a-zA-Z_-]+:.*?## .*$$' Makefile-os | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' @echo "\nAll other commands will be passed through to the docker 'web' container make:" @make -f Makefile-docker help_submake .PHONY: update_docker update_docker: ## update all the docker images docker compose exec --user olympia worker make update_deps docker compose exec --user olympia web make update docker compose restart web docker compose restart worker .PHONY: shell shell: ## connect to a running addons-server docker shell docker compose exec --user olympia web bash .PHONY: rootshell rootshell: ## connect to a running addons-server docker shell with root user docker compose exec --user root web bash .PHONY: create_env_file create_env_file: echo "UID=${UID}\nGID=${GID}" > .env .PHONY: initialize_docker initialize_docker: create_env_file # Run a fresh container from the base image to install deps. Since /deps is # shared via a volume in docker-compose.yml, this installs deps for both web # and worker containers, and does so without requiring the containers to be up. # We just create dummy empty package.json and package-lock.json in deps/ so # that docker compose doesn't create dummy ones itself, as they would be owned # by root. They don't matter: the ones at the root directory are mounted # instead. touch deps/package.json touch deps/package-lock.json # Note that this is running with --user ${UID}:${GID} because the user olympia # would be uid 9500 regardless of host at this point (this is only fixed when # the container is up, through the command defined in docker-compose.yml), # which is wrong for local development. docker compose run --rm --user ${UID}:${GID} web make update_deps docker compose up -d docker compose exec --user olympia web make initialize %: ## This directs any other recipe (command) to the web container's make. docker compose exec --user olympia web make $(MAKECMDGOALS) ARGS=$(ARGS) # You probably want to put new commands in Makefile-docker, unless they operate # on multiple containers or are host-os specific.