wip fixed issues with container start ups

This commit is contained in:
pushrbx 2023-10-24 00:41:28 +01:00
parent c615d652ac
commit 201883d987
4 changed files with 20 additions and 14 deletions

View File

@ -1,12 +1,12 @@
FROM docker.io/spiralscout/roadrunner:2.12.2 as roadrunner FROM docker.io/spiralscout/roadrunner:2.12.2 as roadrunner
FROM docker.io/composer:2.5.1 as composer FROM docker.io/composer:2.5.1 as composer
FROM docker.io/mlocati/php-extension-installer:1.5.52 as php-ext-installer FROM docker.io/mlocati/php-extension-installer:2.1.58 as php-ext-installer
FROM php:8.1.16-bullseye FROM php:8.1.16-bullseye
COPY --from=composer /usr/bin/composer /usr/bin/composer COPY --from=composer /usr/bin/composer /usr/bin/composer
COPY --from=php-ext-installer /usr/bin/install-php-extensions /usr/local/bin/ COPY --from=php-ext-installer /usr/bin/install-php-extensions /usr/local/bin/
ENV COMPOSER_HOME="/tmp/composer" ENV COMPOSER_HOME="/tmp/composer"
RUN set -x \ RUN set -x \
&& install-php-extensions intl bz2 gettext mongodb-stable redis opcache sockets pcntl \ && install-php-extensions intl mbstring mongodb-stable redis opcache sockets pcntl \
# install xdebug (for testing with code coverage), but do not enable it # install xdebug (for testing with code coverage), but do not enable it
&& IPE_DONT_ENABLE=1 install-php-extensions xdebug-3.2.0 && IPE_DONT_ENABLE=1 install-php-extensions xdebug-3.2.0
@ -17,9 +17,8 @@ RUN set -ex \
&& apt-get update && apt-get install -y --no-install-recommends \ && apt-get update && apt-get install -y --no-install-recommends \
openssl \ openssl \
git \ git \
dos2unix \ wget \
unzip \ unzip \
wget \
# install supercronic (for laravel task scheduling), project page: <https://github.com/aptible/supercronic> # install supercronic (for laravel task scheduling), project page: <https://github.com/aptible/supercronic>
&& wget -q "https://github.com/aptible/supercronic/releases/download/v0.1.12/supercronic-linux-$(dpkg --print-architecture)" \ && wget -q "https://github.com/aptible/supercronic/releases/download/v0.1.12/supercronic-linux-$(dpkg --print-architecture)" \
-O /usr/bin/supercronic \ -O /usr/bin/supercronic \

View File

@ -21,6 +21,7 @@ display_help() {
echo "help Print CLI help" echo "help Print CLI help"
echo "build-image Build Image Locally" echo "build-image Build Image Locally"
echo "start Start Jikan API (mongodb, typesense, redis, jikan-api workers)" echo "start Start Jikan API (mongodb, typesense, redis, jikan-api workers)"
echo "stop Stop Jikan API"
echo "validate-prereqs Validate pre-reqs installed (docker, docker-compose)" 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 "execute-indexers Execute the indexers, which will scrape and index data from MAL. (Notice: This can take days)"
echo "" echo ""
@ -69,6 +70,7 @@ validate_prereqs() {
build_image() { build_image() {
validate_prereqs validate_prereqs
$DOCKER_CMD inspect jikanme/jikan-rest:"$_JIKAN_API_VERSION" &> /dev/null && $DOCKER_CMD rmi jikanme/jikan-rest:"$_JIKAN_API_VERSION"
$DOCKER_CMD build --rm --compress -t jikanme/jikan-rest:"$_JIKAN_API_VERSION" . $DOCKER_CMD build --rm --compress -t jikanme/jikan-rest:"$_JIKAN_API_VERSION" .
$DOCKER_CMD tag jikanme/jikan-rest:"$_JIKAN_API_VERSION" jikanme/jikan-rest:latest $DOCKER_CMD tag jikanme/jikan-rest:"$_JIKAN_API_VERSION" jikanme/jikan-rest:latest
} }
@ -116,11 +118,11 @@ case "$1" in
"start") "start")
start start
;; ;;
"stop") "stop")
validate_prereqs validate_prereqs
$DOCKER_COMPOSE_CMD -p "$DOCKER_COMPOSE_PROJECT_NAME" down $DOCKER_COMPOSE_CMD -p "$DOCKER_COMPOSE_PROJECT_NAME" down
;; ;;
"execute-indexers") "execute-indexers")
echo "Indexing anime..." echo "Indexing anime..."
$DOCKER_COMPOSE_CMD -p "$DOCKER_COMPOSE_PROJECT_NAME" exec jikan_rest php /app/artisan indexer:anime $DOCKER_COMPOSE_CMD -p "$DOCKER_COMPOSE_PROJECT_NAME" exec jikan_rest php /app/artisan indexer:anime
echo "Indexing manga..." echo "Indexing manga..."

View File

@ -39,6 +39,10 @@ services:
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
links:
- mongodb
- redis
- typesense
depends_on: depends_on:
mongodb: { condition: service_healthy } mongodb: { condition: service_healthy }
redis: { condition: service_healthy } redis: { condition: service_healthy }
@ -51,7 +55,7 @@ services:
- mongo-data:/data/db - mongo-data:/data/db
ports: ports:
- '27017/tcp' - '27017/tcp'
command: "--wiredTigerCacheSizeGB ${MONGO_CACHE_SIZE_GB:1}" command: "--wiredTigerCacheSizeGB ${MONGO_CACHE_SIZE_GB:-1.0}"
networks: networks:
- jikan_network - jikan_network
secrets: secrets:
@ -61,18 +65,16 @@ services:
MONGO_INITDB_ROOT_USERNAME_FILE: /run/secrets/db_username MONGO_INITDB_ROOT_USERNAME_FILE: /run/secrets/db_username
MONGO_INITDB_ROOT_PASSWORD_FILE: /run/secrets/db_password MONGO_INITDB_ROOT_PASSWORD_FILE: /run/secrets/db_password
healthcheck: healthcheck:
test: echo 'db.runCommand("ping").ok' | mongo mongodb://localhost:27017 --quiet test: echo 'db.runCommand("ping").ok' | mongosh mongodb://localhost:27017 --quiet
interval: 30s interval: 30s
timeout: 10s timeout: 10s
retries: 5 retries: 5
redis: redis:
image: docker.io/redis:7-alpine image: docker.io/redis:6-alpine
hostname: redis hostname: redis
secrets: secrets:
- redis_password - redis_password
environment:
REDIS_PASSWORD: "${REDIS_PASSWORD:-null}"
networks: networks:
- jikan_network - jikan_network
command: command:
@ -99,7 +101,9 @@ services:
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
restart: no deploy:
restart_policy:
condition: none
volumes: volumes:
- typesense-data:/data - typesense-data:/data
ports: ports:

View File

@ -37,7 +37,6 @@ if (!file_exists(".env")) {
$envWriter = new \MirazMac\DotEnv\Writer(__DIR__ . '/' . '.env'); $envWriter = new \MirazMac\DotEnv\Writer(__DIR__ . '/' . '.env');
$itemsWritten = 0; $itemsWritten = 0;
foreach (array_keys($current_env) as $env_key) { foreach (array_keys($current_env) as $env_key) {
echo $env_key;
if (!str_contains($env_key, "__FILE")) { if (!str_contains($env_key, "__FILE")) {
continue; continue;
} }
@ -52,12 +51,14 @@ foreach (array_keys($current_env) as $env_key) {
if ($itemsWritten > 0) { if ($itemsWritten > 0) {
$envWriter->write(); $envWriter->write();
echo "Secrets loaded successfully."; echo "Secrets loaded successfully.\n";
} }
$dotenv = Dotenv::createImmutable(__DIR__); $dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load(); $dotenv->load();
$current_env = $_ENV;
if ($current_env["SCOUT_DRIVER"] === "typesense" && empty($current_env["TYPESENSE_API_KEY"])) { if ($current_env["SCOUT_DRIVER"] === "typesense" && empty($current_env["TYPESENSE_API_KEY"])) {
echo "Please set the TYPESENSE_API_KEY environment variable when setting SCOUT_DRIVER to typesense."; echo "Please set the TYPESENSE_API_KEY environment variable when setting SCOUT_DRIVER to typesense.";
exit(1); exit(1);