2023-03-23 17:46:56 +03:00
|
|
|
UID := $(shell id -u)
|
|
|
|
GID := $(shell id -g)
|
|
|
|
export UID
|
|
|
|
export GID
|
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: help_redirect
|
2017-06-15 11:41:40 +03:00
|
|
|
help_redirect:
|
|
|
|
@$(MAKE) help --no-print-directory
|
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: help_submake
|
2017-06-15 11:41:40 +03:00
|
|
|
help_submake:
|
2019-08-29 14:10:25 +03:00
|
|
|
@echo "Host only commands:"
|
2019-08-29 16:34:26 +03:00
|
|
|
@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:"
|
2019-08-29 14:10:25 +03:00
|
|
|
@make -f Makefile-docker help_submake
|
2017-06-15 11:41:40 +03:00
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: update_docker
|
2019-08-29 16:34:26 +03:00
|
|
|
update_docker: ## update all the docker images
|
2023-05-26 15:05:21 +03:00
|
|
|
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
|
2017-06-15 11:41:40 +03:00
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: shell
|
2019-08-29 16:34:26 +03:00
|
|
|
shell: ## connect to a running addons-server docker shell
|
2023-05-26 15:05:21 +03:00
|
|
|
docker compose exec --user olympia web bash
|
2017-06-15 11:41:40 +03:00
|
|
|
|
2023-03-23 17:46:56 +03:00
|
|
|
.PHONY: rootshell
|
2019-10-22 12:24:05 +03:00
|
|
|
rootshell: ## connect to a running addons-server docker shell with root user
|
2023-05-26 15:05:21 +03:00
|
|
|
docker compose exec --user root web bash
|
2019-10-22 12:24:05 +03:00
|
|
|
|
2023-03-23 17:46:56 +03:00
|
|
|
.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
|
2023-05-26 15:05:21 +03:00
|
|
|
# that docker compose doesn't create dummy ones itself, as they would be owned
|
2023-03-23 17:46:56 +03:00
|
|
|
# by root. They don't matter: the ones at the root directory are mounted
|
|
|
|
# instead.
|
|
|
|
touch deps/package.json
|
2023-03-29 14:49:06 +03:00
|
|
|
touch deps/package-lock.json
|
2023-03-23 17:46:56 +03:00
|
|
|
# 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.
|
2023-05-26 15:05:21 +03:00
|
|
|
docker compose run --rm --user ${UID}:${GID} web make update_deps
|
|
|
|
docker compose up -d
|
|
|
|
docker compose exec --user olympia web make initialize
|
2023-03-23 17:46:56 +03:00
|
|
|
|
2019-08-29 14:40:25 +03:00
|
|
|
%: ## This directs any other recipe (command) to the web container's make.
|
2023-05-26 15:05:21 +03:00
|
|
|
docker compose exec --user olympia web make $(MAKECMDGOALS) ARGS=$(ARGS)
|
2019-08-05 12:44:29 +03:00
|
|
|
|
2019-08-29 14:10:25 +03:00
|
|
|
# You probably want to put new commands in Makefile-docker, unless they operate
|
|
|
|
# on multiple containers or are host-os specific.
|