mirror of
https://github.com/jikan-me/jikan-rest.git
synced 2025-02-20 11:23:35 +08:00
wip setup cli
This commit is contained in:
parent
5f8fd79a4c
commit
9b56d7b397
@ -19,3 +19,7 @@ node_modules
|
||||
.vscode
|
||||
.github
|
||||
.git
|
||||
db_username.txt
|
||||
db_password.txt
|
||||
redis_password.txt
|
||||
typesense_api_key.txt
|
||||
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -17,3 +17,7 @@ composer.phar
|
||||
/coverage
|
||||
.DS_Store
|
||||
*.cache
|
||||
db_username.txt
|
||||
db_password.txt
|
||||
redis_password.txt
|
||||
typesense_api_key.txt
|
||||
|
2
.rr.yaml
2
.rr.yaml
@ -61,7 +61,7 @@ logs:
|
||||
|
||||
# we want to use docker's log drivers, so push logs to stdout
|
||||
output: stdout
|
||||
# we to use docker's log drivers, so push error logs to stdout
|
||||
# we want to use docker's log drivers, so push error logs to stdout
|
||||
# this way it is possible for example to pipe logs to journald or to AWS Cloudwatch
|
||||
err_output: stdout
|
||||
|
||||
|
75
container-setup.sh
Normal file
75
container-setup.sh
Normal file
@ -0,0 +1,75 @@
|
||||
#!/bin/bash
|
||||
|
||||
JIKAN_API_VERSION=v4.0.0-rc.11
|
||||
DOCKER_COMPOSE_PROJECT_NAME=jikan-api-$JIKAN_API_VERSION
|
||||
|
||||
display_help() {
|
||||
echo "============================================================"
|
||||
echo "Jikan API Container Setup CLI"
|
||||
echo "============================================================"
|
||||
echo "Syntax: ./container-setup.sh [command]"
|
||||
echo "Jikan API Version: $JIKAN_API_VERSION"
|
||||
echo "---commands---"
|
||||
echo "help Print CLI help"
|
||||
echo "build-image Build Image Locally"
|
||||
echo "start Start Jikan API (mongodb, typesense, redis, jikan-api workers)"
|
||||
echo "validate-prereqs Validate pre-reqs installed (docker, docker-compose)"
|
||||
echo "execute-indexers Execute the indexers, which will scrape and index data from MAL. (Notice: This can take days)"
|
||||
echo ""
|
||||
}
|
||||
|
||||
validate_prereqs() {
|
||||
docker -v >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "'docker' is not installed or not runnable without sudo. \xE2\x9D\x8C"
|
||||
else
|
||||
echo -e "Docker is Installed. \xE2\x9C\x94"
|
||||
fi
|
||||
|
||||
docker-compose -v >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "'docker-compose' is not installed. \xE2\x9D\x8C"
|
||||
else
|
||||
echo -e "Docker compose is Installed. \xE2\x9C\x94"
|
||||
fi
|
||||
}
|
||||
|
||||
build_image() {
|
||||
docker build --rm --compress -t jikanme/jikan-rest:$JIKAN_API_VERSION .
|
||||
}
|
||||
|
||||
start() {
|
||||
docker-compose -p $DOCKER_COMPOSE_PROJECT_NAME up -d
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
"help")
|
||||
display_help
|
||||
;;
|
||||
"validate-prereqs")
|
||||
validate_prereqs
|
||||
;;
|
||||
"build-image")
|
||||
build_image
|
||||
;;
|
||||
"start")
|
||||
start
|
||||
;;
|
||||
"execute-indexers")
|
||||
echo "Indexing anime..."
|
||||
docker-compose -p $DOCKER_COMPOSE_PROJECT_NAME exec jikan_rest php /app/artisan indexer:anime
|
||||
echo "Indexing manga..."
|
||||
docker-compose -p $DOCKER_COMPOSE_PROJECT_NAME exec jikan_rest php /app/artisan indexer:manga
|
||||
echo "Indexing characters and people..."
|
||||
docker-compose -p $DOCKER_COMPOSE_PROJECT_NAME exec jikan_rest php /app/artisan indexer:common
|
||||
echo "Indexing genres..."
|
||||
docker-compose -p $DOCKER_COMPOSE_PROJECT_NAME exec jikan_rest php /app/artisan indexer:genres
|
||||
echo "Indexing producers..."
|
||||
docker-compose -p $DOCKER_COMPOSE_PROJECT_NAME exec jikan_rest php /app/artisan indexer:producers
|
||||
echo "Indexing done!"
|
||||
;;
|
||||
*)
|
||||
echo "No command specified, displaying help"
|
||||
display_help
|
||||
;;
|
||||
esac
|
@ -4,7 +4,12 @@ volumes:
|
||||
redis-data: { }
|
||||
typesense-data: { }
|
||||
|
||||
networks:
|
||||
jikan_network: { }
|
||||
|
||||
secrets:
|
||||
db_username:
|
||||
file: db_username.txt
|
||||
db_password:
|
||||
file: db_password.txt
|
||||
redis_password:
|
||||
@ -13,48 +18,30 @@ secrets:
|
||||
file: typesense_api_key.txt
|
||||
|
||||
services:
|
||||
jikan_rest: &jikan_rest
|
||||
image: jikanme/jikan-rest:latest
|
||||
jikan_rest:
|
||||
image: jikanme/jikan-rest:v4.0.0-rc.11
|
||||
user: "${APP_UID:-10001}:${APP_GID:-10001}"
|
||||
networks:
|
||||
- jikan_network
|
||||
secrets:
|
||||
- db_username
|
||||
- db_password
|
||||
- typesense_api_key
|
||||
- redis_password
|
||||
environment:
|
||||
PS1: '\[\033[1;32m\]\[\033[1;36m\][\u@\h] \[\033[1;34m\]\w\[\033[0;35m\] \[\033[1;36m\]# \[\033[0m\]'
|
||||
APP_DEBUG: 'false'
|
||||
APP_ENV: production
|
||||
CACHING: 'true'
|
||||
CACHE_DRIVER: redis
|
||||
REDIS_HOST: redis
|
||||
REDIS_PASSWORD__FILE: /run/secrets/redis_password
|
||||
DB_CONNECTION: mongodb
|
||||
DB_HOST: mongodb
|
||||
DB_DATABASE: jikan
|
||||
DB_PORT: 27017
|
||||
DB_ADMIN: "${DB_USERNAME:-root}"
|
||||
DB_USERNAME: "${DB_USERNAME:-root}"
|
||||
SCOUT_DRIVER: typesense
|
||||
SCOUT_QUEUE: 'false'
|
||||
DB_PASSWORD__FILE: /run/secrets/db_password
|
||||
TYPESENSE_HOST: typesense
|
||||
TYPESENSE_PORT: 8108
|
||||
TYPESENSE_API_KEY__FILE: /run/secrets/typesense_api_key
|
||||
CORS_MIDDLEWARE: 'true'
|
||||
MICROCACHING: 'true'
|
||||
MICROCACHING_EXPIRE: 60
|
||||
depends_on:
|
||||
mongodb: { condition: service_healthy }
|
||||
redis: { condition: service_healthy }
|
||||
typesense: { condition: service_healthy }
|
||||
|
||||
web:
|
||||
<<: *jikan_rest
|
||||
env_file:
|
||||
- ./docker/config/.env.compose
|
||||
ports:
|
||||
- '8080:8080/tcp'
|
||||
healthcheck:
|
||||
test: [ 'CMD-SHELL', 'wget --spider -q "http://127.0.0.1:2114/health?plugin=http"' ]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
depends_on:
|
||||
mongodb: { condition: service_healthy }
|
||||
redis: { condition: service_healthy }
|
||||
typesense: { condition: service_healthy }
|
||||
|
||||
mongodb:
|
||||
image: mongo:focal
|
||||
@ -63,6 +50,8 @@ services:
|
||||
ports:
|
||||
- '27017/tcp'
|
||||
command: --wiredTigerCacheSizeGB ${MONGO_CACHE_SIZE_GB:1}
|
||||
networks:
|
||||
- jikan_network
|
||||
secrets:
|
||||
- db_password
|
||||
environment:
|
||||
@ -80,6 +69,8 @@ services:
|
||||
- redis_password
|
||||
environment:
|
||||
REDIS_PASSWORD: "${REDIS_PASSWORD:-null}"
|
||||
networks:
|
||||
- jikan_network
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
@ -98,6 +89,8 @@ services:
|
||||
entrypoint: /bin/sh
|
||||
secrets:
|
||||
- typesense_api_key
|
||||
networks:
|
||||
- jikan_network
|
||||
command:
|
||||
- -c
|
||||
- TYPESENSE_API_KEY="$$(cat /run/secrets/typesense_api_key)" /opt/typesense-server --data-dir /data
|
||||
|
21
docker/config/.env.compose
Normal file
21
docker/config/.env.compose
Normal file
@ -0,0 +1,21 @@
|
||||
APP_DEBUG=false
|
||||
LOG_LEVEL=info
|
||||
APP_ENV=production
|
||||
CACHING=true
|
||||
CACHE_DRIVER=redis
|
||||
REDIS_HOST=redis
|
||||
REDIS_PASSWORD__FILE=/run/secrets/redis_password
|
||||
DB_CONNECTION=mongodb
|
||||
DB_HOST=mongodb
|
||||
DB_DATABASE=jikan
|
||||
DB_USERNAME__FILE=/run/secrets/db_username
|
||||
DB_ADMIN__FILE=/run/secrets/db_username
|
||||
DB_PASSWORD__FILE=/run/secrets/db_password
|
||||
SCOUT_DRIVER=typesense
|
||||
SCOUT_QUEUE=false
|
||||
TYPESENSE_HOST=typesense
|
||||
TYPESENSE_PORT=8108
|
||||
TYPESENSE_API_KEY__FILE=/run/secrets/typesense_api_key
|
||||
CORS_MIDDLEWARE=true
|
||||
MICROCACHING=true
|
||||
MICROCACHING_EXPIRE=60
|
Loading…
x
Reference in New Issue
Block a user