From 251dbbe0f0548c35665963b8e74c6f2e846dd73b Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Sat, 10 Feb 2024 10:37:45 -0300 Subject: [PATCH] FIX: cron ENV vars --- CLI.Dockerfile | 16 ++++++++++------ cli/bin/incoviba | 5 +++++ cli/crontab | 16 ++++++++-------- docker-compose.yml | 28 ++++++---------------------- 4 files changed, 29 insertions(+), 36 deletions(-) create mode 100644 cli/bin/incoviba diff --git a/CLI.Dockerfile b/CLI.Dockerfile index 44eb32c..447f392 100644 --- a/CLI.Dockerfile +++ b/CLI.Dockerfile @@ -1,16 +1,20 @@ -FROM php:8.2-fpm +FROM php:8.2-cli -ENV TZ "America/Santiago" +ENV TZ "${TZ}" +ENV APP_NAME "${APP_NAME}" +ENV API_URL "${API_URL}" -RUN apt-get update && apt-get install -y --no-install-recommends cron && rm -r /var/lib/apt/lists/* +RUN apt-get update && apt-get install -y --no-install-recommends cron rsyslog nano && rm -r /var/lib/apt/lists/* RUN pecl install xdebug-3.2.2 \ - && docker-php-ext-enable xdebug + && docker-php-ext-enable xdebug \ + && echo "#/bin/bash\nprintenv >> /etc/environment\ncron -f -L 11" > /root/entrypoint && chmod a+x /root/entrypoint COPY ./php-errors.ini /usr/local/etc/php/conf.d/docker-php-errors.ini WORKDIR /code/bin -COPY ./cli/crontab /var/spool/cron/crontabs/root +#COPY --chmod=644 ./cli/crontab /etc/cron.d/cronjob +COPY --chmod=644 ./cli/crontab /var/spool/cron/crontabs/root -CMD ["cron", "-f"] +CMD [ "/root/entrypoint" ] diff --git a/cli/bin/incoviba b/cli/bin/incoviba new file mode 100644 index 0000000..7a750c3 --- /dev/null +++ b/cli/bin/incoviba @@ -0,0 +1,5 @@ +#!/bin/bash + +. /etc/profile + +/usr/local/bin/php /code/bin/index.php "$@" \ No newline at end of file diff --git a/cli/crontab b/cli/crontab index 9296d00..865d38e 100644 --- a/cli/crontab +++ b/cli/crontab @@ -1,8 +1,8 @@ -0 2 * * * php /code/bin/index.php ventas:cuotas:hoy 2>&1 >> /logs/commands -0 2 * * * php /code/bin/index.php ventas:cuotas:pendientes 2>&1 >> /logs/commands -0 2 * * * php /code/bin/index.php ventas:cuotas:vencer 2>&1 >> /logs/commands -0 2 * * * php /code/bin/index.php ventas:cierres:vigentes 2>&1 >> /logs/commands -0 2 * * * php /code/bin/index.php proyectos:activos 2>&1 >> /logs/commands -0 2 * * * php /code/bin/index.php comunas 2>&1 >> /logs/commands -0 2 * * * php /code/bin/index.php money:uf 2>&1 >> /logs/commands -0 2 1 * * php /code/bin/index.php money:ipc 2>&1 >> /logs/commands +0 2 * * * /code/bin/incoviba ventas:cuotas:hoy >> /logs/commands 2>&1 +0 2 * * * /code/bin/incoviba ventas:cuotas:pendientes >> /logs/commands 2>&1 +0 2 * * * /code/bin/incoviba ventas:cuotas:vencer >> /logs/commands 2>&1 +0 2 * * * /code/bin/incoviba ventas:cierres:vigentes >> /logs/commands 2>&1 +0 2 * * * /code/bin/incoviba proyectos:activos >> /logs/commands 2>&1 +0 2 * * * /code/bin/incoviba comunas >> /logs/commands 2>&1 +0 2 * * * /code/bin/incoviba money:uf >> /logs/commands 2>&1 +0 2 1 * * /code/bin/incoviba money:ipc >> /logs/commands 2>&1 diff --git a/docker-compose.yml b/docker-compose.yml index ca32980..866cf6f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,15 +1,10 @@ -version: '3' - -x-restart: &restart - restart: unless-stopped - services: proxy: profiles: - app image: nginx:alpine container_name: incoviba_proxy - <<: *restart + restart: unless-stopped ports: - "${APP_PORT}:80" volumes: @@ -22,12 +17,10 @@ services: - app build: . container_name: incoviba_web - <<: *restart + restart: unless-stopped env_file: - ${APP_PATH:-.}/.env -# - ${APP_PATH:-.}/.db.env - ./.key.env - #- ${APP_PATH:-.}/.remote.env volumes: - ${APP_PATH:-.}/:/code - ./logs/php:/logs @@ -37,7 +30,7 @@ services: - db image: mariadb:latest container_name: incoviba_db - <<: *restart + restart: unless-stopped env_file: ${APP_PATH:-.}/.db.env volumes: - dbdata:/var/lib/mysql @@ -53,22 +46,13 @@ services: - cache image: redis container_name: incoviba_redis - <<: *restart + restart: unless-stopped env_file: ${APP_PATH:-.}/.redis.env volumes: - incoviba_redis:/data ports: - "63790:6379" - python: - profiles: - - python - build: - context: . - dockerfile: Python.Dockerfile - container_name: incoviba_python - <<: *restart - logview: profiles: - log @@ -81,7 +65,7 @@ services: WEB_URL: 'http://provm.cl:8084' WEB_PORT: '8084' volumes: - - "./logs:/logs" + - ./logs:/logs ports: - "8084:80" cli: @@ -91,7 +75,7 @@ services: context: . dockerfile: CLI.Dockerfile container_name: incoviba_cli - <<: *restart + restart: unless-stopped env_file: - ${CLI_PATH:-.}/.env - ./.key.env