Skip to content

Commit

Permalink
cmd container wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nmaillat committed Dec 12, 2023
1 parent e8471a1 commit f7263fc
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 18 deletions.
15 changes: 9 additions & 6 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@
# - "gateway-traefik" : nginx is launched behind a traefik service, the traefik is include in this stack (todo)
# or Traefik include in Phrasea Stack.
# - "workers" : launch one worker container by kind of Jobs, you can also
# choose to launch only some workers, see worker list below.
# choose to launch only some workers, see worker profile list below.
# - "worker" : launch one container worker with all jobs run on it.
# - "cmd" : launch a container based on worker image, useful for run cmd manualy.
# - "db" : launch a mariadb container, because this is the primary
# datastore for production usage, use your own service.
# - "elastisearch" : launch a elasticsearch container.
Expand Down Expand Up @@ -89,11 +90,11 @@
#
# For development:
# - COMPOSE_FILE=docker-compose.yml:docker-compose.datastores.yml:docker-compose.tools.yml:docker-compose.override.yml
# - COMPOSE_PROFILES=app,setup,db,pma,elasticsearch,redis,redis-session,rabbitmq,workers,mailhog,builder,gateway-classic
# - COMPOSE_PROFILES=app,setup,db,pma,elasticsearch,redis,redis-session,rabbitmq,workers,mailhog,builder,gateway-classic,cmd
#
# For testing with tools:
# - COMPOSE_FILE=docker-compose.yml:docker-compose.datastores.yml:docker-compose.tools.yml
# - COMPOSE_PROFILES=app,setup,db,pma,elasticsearch,rabbitmq,redis,redis-session,worker,workers,mailhog,gateway-classic
# - COMPOSE_PROFILES=app,setup,db,pma,elasticsearch,rabbitmq,redis,redis-session,workers,,cmd,mailhog,gateway-classic
#
# For testing with debug and SSL (the traekik is provide by Phrasea stack):
# - COMPOSE_FILE=docker-compose.yml:docker-compose.datastores.yml:docker-compose.tools.yml:docker-compose.under-phrasea.yml
Expand All @@ -107,7 +108,7 @@
# - COMPOSE_FILE=docker-compose.yml:docker-compose.datastores.yml:docker-compose.tools.yml
# - COMPOSE_PROFILES=app,setup,gateway-classic,db,elasticsearch,redis,redis-session,rabbitmq,pma,mailhog,assetsInjest,createRecord,deleteRecord,editRecord,
# exportMail,downloadAsync,exposeUpload,exportFtp,mainQueue,populateIndex,pullAssets,recordsActions,subdefCreation,
# validationReminder,webhook,writeMetadatas,shareBasket,scheduler,elk,db-backup,phraseanet-saml-sp
# validationReminder,webhook,writeMetadatas,shareBasket,scheduler,cmd,elk,db-backup,phraseanet-saml-sp
#


Expand All @@ -134,7 +135,7 @@ PHRASEANET_DOCKER_REGISTRY=local

# Docker images tag.
# @run
PHRASEANET_DOCKER_TAG=4.1.8-rc8
PHRASEANET_DOCKER_TAG=4.1.8-rc7

# Stack Name
# An optionnal Name for the stack
Expand Down Expand Up @@ -772,7 +773,9 @@ PHRASEANET_WORKER_writeMetadatas=1
# @run
PHRASEANET_WORKER_shareBasket=1


# PHRASEANET_CMD_MODE=1, set a worker container for run bin/console... or bin/maintenance... manualy
# @run
PHRASEANET_CMD_MODE

# --- Phraseanet Locales settings --------------------------------------------------------------------------------------

Expand Down
7 changes: 7 additions & 0 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@ services:
- internal

scheduler:
volumes:
- ../:/var/alchemy
- .:/var/alchemy/Phraseanet
networks:
- internal

cmd:
volumes:
- ../:/var/alchemy
- .:/var/alchemy/Phraseanet
Expand Down
44 changes: 43 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ services:
- LC_NAME=C.UTF-8
- PHRASEANET_EXPLODE_WORKER
- PHRASEANET_WORKERS_LAUNCH_METHOD
- PHRASEANET_WORKER_CUSTOM
- PHRASEANET_WORKER_assetsIngest
- PHRASEANET_WORKER_createRecord
- PHRASEANET_WORKER_deleteRecord
Expand Down Expand Up @@ -1314,6 +1313,49 @@ services:
- ${PHRASEANET_TMP_DIR}:/var/alchemy/Phraseanet/tmp:rw
networks:
- internal

cmd:
build:
context: .
target: phraseanet-worker
args:
- SSH_PRIVATE_KEY=${PHRASEANET_SSH_PRIVATE_KEY}
- PHRASEANET_PLUGINS=${PHRASEANET_PLUGINS}
image: $PHRASEANET_DOCKER_REGISTRY/phraseanet-worker:$PHRASEANET_DOCKER_TAG
profiles: ["cmd"]
restart: on-failure
depends_on:
- phraseanet
environment:
- STACK_NAME
- OPCACHE_ENABLED
- SESSION_CACHE_LIMITER
- PHP_LOG_LEVEL
- PHP_CLI_MEMORY_LIMIT
- LC_MESSAGES=C.UTF-8
- LC_COLLATE=C.UTF-8
- LC_IDENTIFICATION=C.UTF-8
- LANG=C.UTF-8
- LC_MEASUREMENT=C.UTF-8
- LC_CTYPE=C.UTF-8
- LC_TIME=C.UTF-8
- LC_NAME=C.UTF-8
- PHRASEANET_CMD_MODE
- PHRASEANET_EXPLODE_WORKER
- PHRASEANET_WORKERS_LAUNCH_METHOD
- NEWRELIC_ENABLED
- NEWRELIC_LICENSE_KEY
- NEWRELIC_APP_NAME
volumes:
- ${PHRASEANET_CONFIG_DIR}:/var/alchemy/Phraseanet/config:rw
- ${PHRASEANET_LOGS_DIR}:/var/alchemy/Phraseanet/logs:rw
- ${PHRASEANET_DATA_DIR}:/var/alchemy/Phraseanet/datas:rw
- ${PHRASEANET_THUMBNAILS_DIR}:/var/alchemy/Phraseanet/www/thumbnails:rw
- ${PHRASEANET_CUSTOM_DIR}:/var/alchemy/Phraseanet/www/custom:rw
- ${PHRASEANET_CACHE_DIR}:/var/alchemy/Phraseanet/cache:rw
- ${PHRASEANET_TMP_DIR}:/var/alchemy/Phraseanet/tmp:rw
networks:
- internal


volumes:
Expand Down
11 changes: 0 additions & 11 deletions docker/phraseanet/fpm/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,6 @@ else
rm -f /usr/local/etc/php/conf.d/newrelic.ini
fi

if [[ $BLACKFIRE_ENABLED = "true" ]]; then
echo `date +"%Y-%m-%d %H:%M:%S"` " - BlackFire setup."
blackfire-agent --register --server-id=$BLACKFIRE_SERVER_ID --server-token=$BLACKFIRE_SERVER_TOKEN
service blackfire-agent start
echo "Blackfire setup done"
else
echo `date +"%Y-%m-%d %H:%M:%S"` " - blackfire extension deactivation."
rm -f /usr/local/etc/php/conf.d/zz-blackfire.ini
fi


./docker/phraseanet/plugins/console init

chown -R app:app cache
Expand Down
5 changes: 5 additions & 0 deletions docker/phraseanet/worker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ else
fi
done

if [ ! -z "$PHRASEANET_CMD_MODE" ] && [ ${PHRASEANET_CMD_MODE} == "1" ] ; then
apt update
apt install screen
echo "Worker are in custom process mode"
fi

echo $NBR_WORKERS " workers defined"
echo $NBR_WORKERS > bin/workers_count.txt
Expand Down

0 comments on commit f7263fc

Please sign in to comment.