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
|
.vscode
|
||||||
.github
|
.github
|
||||||
.git
|
.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
|
/coverage
|
||||||
.DS_Store
|
.DS_Store
|
||||||
*.cache
|
*.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
|
# we want to use docker's log drivers, so push logs to stdout
|
||||||
output: 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
|
# this way it is possible for example to pipe logs to journald or to AWS Cloudwatch
|
||||||
err_output: stdout
|
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: { }
|
redis-data: { }
|
||||||
typesense-data: { }
|
typesense-data: { }
|
||||||
|
|
||||||
|
networks:
|
||||||
|
jikan_network: { }
|
||||||
|
|
||||||
secrets:
|
secrets:
|
||||||
|
db_username:
|
||||||
|
file: db_username.txt
|
||||||
db_password:
|
db_password:
|
||||||
file: db_password.txt
|
file: db_password.txt
|
||||||
redis_password:
|
redis_password:
|
||||||
@ -13,48 +18,30 @@ secrets:
|
|||||||
file: typesense_api_key.txt
|
file: typesense_api_key.txt
|
||||||
|
|
||||||
services:
|
services:
|
||||||
jikan_rest: &jikan_rest
|
jikan_rest:
|
||||||
image: jikanme/jikan-rest:latest
|
image: jikanme/jikan-rest:v4.0.0-rc.11
|
||||||
user: "${APP_UID:-10001}:${APP_GID:-10001}"
|
user: "${APP_UID:-10001}:${APP_GID:-10001}"
|
||||||
|
networks:
|
||||||
|
- jikan_network
|
||||||
secrets:
|
secrets:
|
||||||
|
- db_username
|
||||||
- db_password
|
- db_password
|
||||||
- typesense_api_key
|
- typesense_api_key
|
||||||
|
- redis_password
|
||||||
environment:
|
environment:
|
||||||
PS1: '\[\033[1;32m\]\[\033[1;36m\][\u@\h] \[\033[1;34m\]\w\[\033[0;35m\] \[\033[1;36m\]# \[\033[0m\]'
|
PS1: '\[\033[1;32m\]\[\033[1;36m\][\u@\h] \[\033[1;34m\]\w\[\033[0;35m\] \[\033[1;36m\]# \[\033[0m\]'
|
||||||
APP_DEBUG: 'false'
|
env_file:
|
||||||
APP_ENV: production
|
- ./docker/config/.env.compose
|
||||||
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
|
|
||||||
ports:
|
ports:
|
||||||
- '8080:8080/tcp'
|
- '8080:8080/tcp'
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: [ 'CMD-SHELL', 'wget --spider -q "http://127.0.0.1:2114/health?plugin=http"' ]
|
test: [ 'CMD-SHELL', 'wget --spider -q "http://127.0.0.1:2114/health?plugin=http"' ]
|
||||||
interval: 2s
|
interval: 2s
|
||||||
timeout: 2s
|
timeout: 2s
|
||||||
|
depends_on:
|
||||||
|
mongodb: { condition: service_healthy }
|
||||||
|
redis: { condition: service_healthy }
|
||||||
|
typesense: { condition: service_healthy }
|
||||||
|
|
||||||
mongodb:
|
mongodb:
|
||||||
image: mongo:focal
|
image: mongo:focal
|
||||||
@ -63,6 +50,8 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- '27017/tcp'
|
- '27017/tcp'
|
||||||
command: --wiredTigerCacheSizeGB ${MONGO_CACHE_SIZE_GB:1}
|
command: --wiredTigerCacheSizeGB ${MONGO_CACHE_SIZE_GB:1}
|
||||||
|
networks:
|
||||||
|
- jikan_network
|
||||||
secrets:
|
secrets:
|
||||||
- db_password
|
- db_password
|
||||||
environment:
|
environment:
|
||||||
@ -80,6 +69,8 @@ services:
|
|||||||
- redis_password
|
- redis_password
|
||||||
environment:
|
environment:
|
||||||
REDIS_PASSWORD: "${REDIS_PASSWORD:-null}"
|
REDIS_PASSWORD: "${REDIS_PASSWORD:-null}"
|
||||||
|
networks:
|
||||||
|
- jikan_network
|
||||||
command:
|
command:
|
||||||
- /bin/sh
|
- /bin/sh
|
||||||
- -c
|
- -c
|
||||||
@ -98,6 +89,8 @@ services:
|
|||||||
entrypoint: /bin/sh
|
entrypoint: /bin/sh
|
||||||
secrets:
|
secrets:
|
||||||
- typesense_api_key
|
- typesense_api_key
|
||||||
|
networks:
|
||||||
|
- jikan_network
|
||||||
command:
|
command:
|
||||||
- -c
|
- -c
|
||||||
- TYPESENSE_API_KEY="$$(cat /run/secrets/typesense_api_key)" /opt/typesense-server --data-dir /data
|
- 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