diff --git a/compose.yml b/compose.yml index c83669a..55efea8 100755 --- a/compose.yml +++ b/compose.yml @@ -33,11 +33,12 @@ services: worker: - build: - dockerfile: docker/Dockerfile.base.worker - context: . - args: - FRANKENPHP_TAG: php8.4-alpine +# build: +# dockerfile: docker/Dockerfile.base.worker +# context: . +# args: +# FRANKENPHP_TAG: php8.4-alpine + image: torsearch-alpine restart: unless-stopped volumes: - $PWD:/app @@ -45,7 +46,7 @@ services: tty: true environment: TZ: America/Chicago - command: php /app/bin/console messenger:consume async --time-limit=3600 -vv +# command: php /app/bin/console messenger:consume async --time-limit=3600 -vv scheduler: @@ -96,6 +97,8 @@ services: image: adminer ports: - "8081:8080" + environment: + ADMINER_DEFAULT_SERVER: database volumes: diff --git a/config/packages/messenger.yaml b/config/packages/messenger.yaml index 13e9d14..a970130 100644 --- a/config/packages/messenger.yaml +++ b/config/packages/messenger.yaml @@ -15,6 +15,26 @@ framework: max_retries: 1 multiplier: 1 + download: + dsn: '%env(MESSENGER_TRANSPORT_DSN)%' + options: + use_notify: true + check_delayed_interval: 60000 + queue_name: download + retry_strategy: + max_retries: 1 + multiplier: 1 + + monitor: + dsn: '%env(MESSENGER_TRANSPORT_DSN)%' + options: + use_notify: true + check_delayed_interval: 60000 + queue_name: monitor + retry_strategy: + max_retries: 1 + multiplier: 1 + media_cache: dsn: '%env(MESSENGER_TRANSPORT_DSN)%' options: @@ -36,7 +56,7 @@ framework: routing: # Route your messages to the transports # 'App\Message\YourMessage': async - 'App\Download\Action\Command\DownloadMediaCommand': async + 'App\Download\Action\Command\DownloadMediaCommand': download 'App\Download\Action\Command\DownloadSeasonCommand': async 'App\Monitor\Action\Command\MonitorTvEpisodeCommand': async 'App\Monitor\Action\Command\MonitorTvSeasonCommand': async diff --git a/deploy.compose.yml b/deploy.compose.yml index e874918..d47aca5 100755 --- a/deploy.compose.yml +++ b/deploy.compose.yml @@ -29,16 +29,16 @@ services: depends_on: - app - - scheduler: - image: registry.caldwell.digital/home/torsearch-scheduler:${TAG} - volumes: - - /mnt/media/downloads/movies:/var/download/movies - - /mnt/media/downloads/tvshows:/var/download/tvshows - restart: always - command: -vv - depends_on: - - app +# +# scheduler: +# image: registry.caldwell.digital/home/torsearch-scheduler:${TAG} +# volumes: +# - /mnt/media/downloads/movies:/var/download/movies +# - /mnt/media/downloads/tvshows:/var/download/tvshows +# restart: always +# command: -vv +# depends_on: +# - app redis: diff --git a/docker/Dockerfile.worker b/docker/Dockerfile.worker index 7039678..03576c7 100644 --- a/docker/Dockerfile.worker +++ b/docker/Dockerfile.worker @@ -1,10 +1,40 @@ -FROM code.caldwell.digital/home/torsearch-base-worker:php8.4-alpine +### +# This version of Torsearch runs the scheduler, downloader, and worker +# in this one container. Each process is managerd by supervisord +# and can be configured via environment variables and more +# than one of these containers cans till be run. +### +ARG APP_VERSION="latest" -ARG APP_VERSION="0.0.0-dev" -ENV APP_VERSION="${APP_VERSION}" +FROM code.caldwell.digital/home/torsearch-app:${APP_VERSION} AS base_image -COPY . /app -ENTRYPOINT [ "php", "/app/bin/console", "messenger:consume", "async" ] +FROM alpine:3.22 AS build_stage -HEALTHCHECK --interval=3s --timeout=3s --retries=10 CMD return 0 +COPY --from=base_image --chown=1000:1000 /app /app + +RUN apk add --no-cache \ + curl \ + nginx \ + php84 \ + php84-ctype \ + php84-curl \ + php84-dom \ + php84-fileinfo \ + php84-fpm \ + php84-gd \ + php84-mbstring \ + php84-mysqli \ + php84-opcache \ + php84-openssl \ + php84-pdo_mysql \ + php84-tokenizer \ + supervisor + +RUN ln -s /usr/bin/php84 /usr/bin/php + +COPY docker/worker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf + +# We start supervisord and supervisord starts +# respective service in the configuration file. +CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] diff --git a/docker/worker/supervisord.conf b/docker/worker/supervisord.conf new file mode 100644 index 0000000..3ec6723 --- /dev/null +++ b/docker/worker/supervisord.conf @@ -0,0 +1,27 @@ +[supervisord] +nodaemon=true +logfile=/dev/null +logfile_maxbytes=0 +pidfile=/run/supervisord.pid + +[program:torsearch-worker] +command=/app/bin/console messenger:consume download -vv --time-limit 3600 +numprocs=1 +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +autorestart=true +startretries=3 +process_name=%(program_name)s_%(process_num)02d + +[program:torsearch-scheduler] +command=/app/bin/console messenger:consume monitor -vv +numprocs=1 +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +autorestart=true +startretries=3 +process_name=%(program_name)s_%(process_num)02d