2021-10-29 01:24:43 +09:00
|
|
|
|
2021-08-06 20:14:03 +09:00
|
|
|
DIR=$(strip $(notdir $(CURDIR))) # Seems a bit hack-ish, but `basename` works differently
|
2021-05-02 21:39:32 +09:00
|
|
|
|
2021-10-18 23:20:50 +09:00
|
|
|
translate-container-name = $$(if docker container inspect $(1) > /dev/null 2>&1; then echo $(1); else echo $(1) | sed 'y/_/-/' ; fi)
|
2021-10-29 01:24:43 +09:00
|
|
|
args = `arg="$(filter-out $@,$(MAKECMDGOALS))" && echo $${arg:-${1}}`
|
|
|
|
|
|
|
|
%:
|
|
|
|
@:
|
2021-10-18 23:20:50 +09:00
|
|
|
|
2021-08-06 20:14:03 +09:00
|
|
|
.PHONY:
|
2021-08-19 01:25:23 +09:00
|
|
|
@if ! docker info > /dev/null; then echo "Docker does not seem to be running"; exit 1; fi
|
2021-08-06 20:14:03 +09:00
|
|
|
|
|
|
|
up: .PHONY
|
|
|
|
docker-compose up -d
|
|
|
|
|
|
|
|
down: .PHONY
|
|
|
|
docker-compose down
|
|
|
|
|
2021-08-17 06:07:24 +09:00
|
|
|
redis-shell:
|
2021-10-18 23:20:50 +09:00
|
|
|
docker exec -it $(call translate-container-name,$(strip $(DIR))_redis_1) sh -c 'redis-cli'
|
2021-08-17 06:07:24 +09:00
|
|
|
|
2021-08-06 20:14:03 +09:00
|
|
|
php-repl: .PHONY
|
2021-10-18 23:20:50 +09:00
|
|
|
docker exec -it $(call translate-container-name,$(strip $(DIR))_php_1) sh -c '/var/www/social/bin/console psysh'
|
2021-08-06 20:14:03 +09:00
|
|
|
|
|
|
|
php-shell: .PHONY
|
2021-10-18 23:20:50 +09:00
|
|
|
docker exec -it $(call translate-container-name,$(strip $(DIR))_php_1) sh -c 'cd /var/www/social; sh'
|
2021-08-06 20:14:03 +09:00
|
|
|
|
|
|
|
psql-shell: .PHONY
|
2021-10-18 23:20:50 +09:00
|
|
|
docker exec -it $(call translate-container-name,$(strip $(DIR))_db_1) sh -c "psql -U postgres social"
|
2021-08-06 20:14:03 +09:00
|
|
|
|
2021-11-02 19:40:01 +09:00
|
|
|
database-force-nuke:
|
2021-11-24 07:10:16 +09:00
|
|
|
docker stop $(call translate-container-name,$(strip $(DIR))_worker_1) \
|
|
|
|
&& docker exec -it $(call translate-container-name,$(strip $(DIR))_php_1) sh -c "cd /var/www/social; bin/console doctrine:database:drop --force && bin/console doctrine:database:create && bin/console doctrine:schema:update --dump-sql --force && bin/console app:populate_initial_values" \
|
|
|
|
&& docker-compose up -d
|
2021-11-02 19:40:01 +09:00
|
|
|
|
2021-08-17 06:07:24 +09:00
|
|
|
database-force-schema-update:
|
2021-10-18 23:20:50 +09:00
|
|
|
docker exec -it $(call translate-container-name,$(strip $(DIR))_php_1) sh -c "/var/www/social/bin/console doctrine:schema:update --dump-sql --force"
|
2021-08-17 06:07:24 +09:00
|
|
|
|
2022-10-30 03:52:35 +09:00
|
|
|
tooling-docker-up: .PHONY
|
2022-10-30 00:57:40 +09:00
|
|
|
@sh -c 'if [ ! docker container inspect $(call translate-container-name,tooling_php_1) > /dev/null 2>&1 ]; then cd docker/tooling && docker-compose up -d --build > /dev/null 2>&1; fi'
|
2021-05-02 23:49:34 +09:00
|
|
|
|
2022-10-30 03:52:35 +09:00
|
|
|
tooling-docker-down: .PHONY
|
2022-01-09 23:45:33 +09:00
|
|
|
cd docker/tooling && docker-compose down
|
|
|
|
|
2022-10-30 03:52:35 +09:00
|
|
|
test: tooling-docker-up
|
|
|
|
@docker exec $(call translate-container-name,tooling_php_1) /var/tooling/coverage.sh $(call args,'')
|
|
|
|
|
|
|
|
test-database-force-nuke: tooling-docker-up
|
|
|
|
docker exec -it $(call translate-container-name,tooling_php_1) sh -c 'cd /var/www/social; bin/console doctrine:database:drop --force'
|
|
|
|
|
|
|
|
tooling-php-shell: tooling-docker-up
|
2022-01-09 23:45:33 +09:00
|
|
|
docker exec -it $(call translate-container-name,tooling_php_1) sh
|
|
|
|
|
2022-10-30 03:52:35 +09:00
|
|
|
test-accesibility: tooling-docker-up
|
2022-01-19 02:17:07 +09:00
|
|
|
cd docker/tooling && docker-compose run pa11y /accessibility.sh
|
2021-12-02 04:50:25 +09:00
|
|
|
|
2022-10-30 03:52:35 +09:00
|
|
|
cs-fixer: tooling-docker-up
|
2021-12-27 00:13:37 +09:00
|
|
|
@bin/php-cs-fixer $${CS_FIXER_FILE}
|
2021-12-25 23:26:59 +09:00
|
|
|
|
2022-10-30 03:52:35 +09:00
|
|
|
doc-check: tooling-docker-up
|
2021-12-25 23:26:59 +09:00
|
|
|
bin/php-doc-check
|
2021-10-21 22:44:21 +09:00
|
|
|
|
2022-10-30 03:52:35 +09:00
|
|
|
phpstan: tooling-docker-up
|
2021-10-21 23:11:00 +09:00
|
|
|
bin/phpstan
|
2021-09-09 08:40:34 +09:00
|
|
|
|
2021-12-24 02:31:20 +09:00
|
|
|
remove-var:
|
|
|
|
rm -rf var/*
|
|
|
|
|
2021-12-26 13:18:34 +09:00
|
|
|
remove-file:
|
2022-01-18 05:49:36 +09:00
|
|
|
sudo rm -rf file/*
|
2021-12-26 13:18:34 +09:00
|
|
|
|
2021-12-24 02:31:20 +09:00
|
|
|
flush-redis-cache:
|
|
|
|
docker exec -it $(call translate-container-name,$(strip $(DIR))_redis_1) sh -c 'redis-cli flushall'
|
|
|
|
|
2022-02-26 21:18:40 +09:00
|
|
|
install-plugins:
|
|
|
|
docker exec -it $(call translate-container-name,$(strip $(DIR))_php_1) /var/www/social/bin/install_plugins.sh
|
|
|
|
|
2022-02-26 23:04:47 +09:00
|
|
|
update-dependencies:
|
|
|
|
docker exec -it $(call translate-container-name,$(strip $(DIR))_php_1) sh -c 'cd /var/www/social && composer update'
|
|
|
|
|
|
|
|
update-autocode:
|
|
|
|
docker exec -it $(call translate-container-name,$(strip $(DIR))_php_1) sh -c 'cd /var/www/social && bin/update_autocode'
|
|
|
|
|
2022-03-01 08:37:16 +09:00
|
|
|
backup-actors:
|
|
|
|
docker exec -it $(call translate-container-name,$(strip $(DIR))_db_1) \
|
|
|
|
sh -c 'su postgres -c "mkdir -p /tmp/backup"' && \
|
|
|
|
docker exec -it $(call translate-container-name,$(strip $(DIR))_php_1) \
|
|
|
|
sh -c "cd /var/www/social && bin/console doctrine:query:sql \"\
|
2022-03-08 00:47:52 +09:00
|
|
|
copy actor to '/tmp/backup/actor.csv';\
|
|
|
|
copy local_user to '/tmp/backup/local_user.csv';\
|
|
|
|
copy local_group to '/tmp/backup/local_group.csv';\
|
|
|
|
\
|
|
|
|
copy activitypub_actor to '/tmp/backup/ap_actor.csv';\
|
|
|
|
copy activitypub_rsa to '/tmp/backup/ap_rsa.csv';\
|
|
|
|
\
|
|
|
|
copy actor_subscription to '/tmp/backup/actor_subscription.csv';\
|
|
|
|
copy group_member to '/tmp/backup/group_member.csv';\
|
|
|
|
\
|
2022-03-02 03:06:50 +09:00
|
|
|
copy feed to '/tmp/backup/feed.csv';\
|
2022-03-01 08:37:16 +09:00
|
|
|
copy (SELECT 'ALTER SEQUENCE ' || c.relname || ' RESTART WITH ' || nextval(c.relname::regclass) || ';'\
|
|
|
|
FROM pg_class c WHERE c.relkind = 'S') to '/tmp/backup/sequences';\"" && \
|
|
|
|
mkdir -p /tmp/social-sql-backup && \
|
|
|
|
docker cp $(call translate-container-name,$(strip $(DIR))_db_1):/tmp/backup/. /tmp/social-sql-backup
|
|
|
|
|
|
|
|
restore-actors:
|
|
|
|
docker cp /tmp/social-sql-backup/. $(call translate-container-name,$(strip $(DIR))_db_1):/tmp/backup
|
|
|
|
docker exec -it $(call translate-container-name,$(strip $(DIR))_db_1) sh -c 'chown postgres /tmp/backup' && \
|
|
|
|
docker exec -it $(call translate-container-name,$(strip $(DIR))_php_1) \
|
|
|
|
sh -c "cd /var/www/social && bin/console doctrine:query:sql \"\
|
2022-03-08 00:47:52 +09:00
|
|
|
copy actor from '/tmp/backup/actor.csv';\
|
|
|
|
copy local_user from '/tmp/backup/local_user.csv';\
|
|
|
|
copy local_group from '/tmp/backup/local_group.csv';\
|
|
|
|
\
|
|
|
|
copy activitypub_actor from '/tmp/backup/ap_actor.csv';\
|
|
|
|
copy activitypub_rsa from '/tmp/backup/ap_rsa.csv';\
|
|
|
|
\
|
|
|
|
copy actor_subscription from '/tmp/backup/actor_subscription.csv';\
|
|
|
|
copy group_member from '/tmp/backup/group_member.csv';\
|
|
|
|
\
|
2022-03-02 03:06:50 +09:00
|
|
|
copy feed from '/tmp/backup/feed.csv';\
|
2022-03-01 08:37:16 +09:00
|
|
|
`cat /tmp/social-sql-backup/sequences`\""
|
|
|
|
|
2022-02-26 21:18:40 +09:00
|
|
|
force-nuke-everything: down remove-var remove-file up flush-redis-cache database-force-nuke install-plugins
|
2022-03-01 08:37:16 +09:00
|
|
|
|
|
|
|
force-delete-content: backup-actors force-nuke-everything restore-actors
|