Skip to content

Commit

Permalink
chore: fix docker compose cli (#563)
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa authored Apr 4, 2024
1 parent 29826c3 commit 659b321
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
32 changes: 16 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SCHEMACHECK ?= docker run --rm -i hiogawa/schemacheck # https://github.com/hi-og
lint: lint/docker-compose lint/shellcheck lint/github-workflow

lint/docker-compose:
docker-compose config -q
docker compose config -q

lint/shellcheck:
$(SHELLCHECK) scripts/*.sh $$(find misc -name '*.sh')
Expand All @@ -40,20 +40,20 @@ db/seed-download:
wget --retry-on-http-error=403,503 -c -P misc/fixture https://github.com/hi-ogawa/ytsub-v3/files/11279701/fetchCaptionEntries-EnPYXckiUVg-fr-en.txt

db/dump:
docker-compose exec -T mysql mysqldump -uroot -ppassword ytsub_development | gzip -c > "misc/db/dump/$$(date '+%Y_%m_%d_%H_%M_%S').sql.gz"
docker compose exec -T mysql mysqldump -uroot -ppassword ytsub_development | gzip -c > "misc/db/dump/$$(date '+%Y_%m_%d_%H_%M_%S').sql.gz"

db/restore:
gunzip -c $$(ls misc/db/dump/*.sql.gz | tail -n 1) | docker-compose exec -T mysql mysql -uroot -ppassword ytsub_development
gunzip -c $$(ls misc/db/dump/*.sql.gz | tail -n 1) | docker compose exec -T mysql mysql -uroot -ppassword ytsub_development

db/restore/dev:
gunzip -c misc/db/dev.sql.gz | docker-compose exec -T mysql mysql -uroot -ppassword ytsub_development
gunzip -c misc/db/dev.sql.gz | docker compose exec -T mysql mysql -uroot -ppassword ytsub_development

db/dump/production:
pscale org switch hiro18181-ytsub
pscale database dump ytsub_production main --output misc/db/dump-pscale/$$(date '+%Y_%m_%d_%H_%M_%S')

db/restore/production:
ls $$(find misc/db/dump-pscale -mindepth 1 -type d | sort | tail -n 1)/*.sql | sort | xargs cat | docker-compose exec -T mysql mysql -uroot -ppassword --default-character-set=utf8mb4 ytsub_development
ls $$(find misc/db/dump-pscale -mindepth 1 -type d | sort | tail -n 1)/*.sql | sort | xargs cat | docker compose exec -T mysql mysql -uroot -ppassword --default-character-set=utf8mb4 ytsub_development

db/reset: db/recreate db/migrate
db/reset/dev: db/recreate/dev db/migrate/dev
Expand All @@ -62,10 +62,10 @@ db/reset/test: db/recreate/test db/migrate/test
db/recreate: db/recreate/dev db/recreate/test

db/recreate/dev:
docker-compose exec -T mysql mysql -uroot -ppassword -e 'DROP DATABASE IF EXISTS ytsub_development; CREATE DATABASE ytsub_development;'
docker compose exec -T mysql mysql -uroot -ppassword -e 'DROP DATABASE IF EXISTS ytsub_development; CREATE DATABASE ytsub_development;'

db/recreate/test:
docker-compose exec -T mysql mysql -uroot -ppassword -e 'DROP DATABASE IF EXISTS ytsub_test; CREATE DATABASE ytsub_test;'
docker compose exec -T mysql mysql -uroot -ppassword -e 'DROP DATABASE IF EXISTS ytsub_test; CREATE DATABASE ytsub_test;'

db/migrate: db/migrate/dev db/migrate/test

Expand All @@ -76,28 +76,28 @@ db/migrate/test:
NODE_ENV=test pnpm knex migrate:latest

db/log/view:
docker-compose exec mysql tail -f /var/lib/mysql/__general.log
docker compose exec mysql tail -f /var/lib/mysql/__general.log

db/log/enable:
docker-compose exec -T mysql mysql -uroot -ppassword -e "SET global log_output = 'FILE'; SET global general_log_file='/var/lib/mysql/__general.log'; SET global general_log = 1;"
docker compose exec -T mysql mysql -uroot -ppassword -e "SET global log_output = 'FILE'; SET global general_log_file='/var/lib/mysql/__general.log'; SET global general_log = 1;"

db/log/disable:
docker-compose exec -T mysql mysql -uroot -ppassword -e "SET global general_log = 0;"
docker compose exec -T mysql mysql -uroot -ppassword -e "SET global general_log = 0;"

db/console/dev:
docker-compose exec mysql mysql -uroot -ppassword ytsub_development
docker compose exec mysql mysql -uroot -ppassword ytsub_development

#
# docker
#

docker/up:
docker-compose up -d
docker-compose run --rm dockerize -timeout 60s -wait tcp://mysql:3306
docker compose up -d
docker compose run --rm dockerize -timeout 60s -wait tcp://mysql:3306

docker/down:
docker-compose down
docker compose down

docker/clean:
docker-compose down -v --remove-orphans
docker-compose rm -f -s -v
docker compose down -v --remove-orphans
docker compose rm -f -s -v
2 changes: 1 addition & 1 deletion app/utils/opentelemetry-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { NodeSDK } from "@opentelemetry/sdk-node";
OTEL_SERVICE_NAME=dev OTEL_TRACES_EXPORTER=console pnpm dev
# see logs on local jaeger
docker-compose up jaeger # open http://localhost:16686
docker compose up jaeger # open http://localhost:16686
OTEL_SERVICE_NAME=dev OTEL_TRACES_EXPORTER=otlp OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/json pnpm dev
```
*/
Expand Down

0 comments on commit 659b321

Please sign in to comment.