Skip to content

Commit

Permalink
polish containers
Browse files Browse the repository at this point in the history
  • Loading branch information
bailletced committed Jan 23, 2025
1 parent a65af9a commit 8e6ae66
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
7 changes: 7 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ services:
ELASTIC_PASSWORD: admin
ELASTICSEARCH_IRI: http://elastic:admin@elasticsearch:9200
SYNCHRO_SECRET_KEY: "secret"
ROLE: api
cli:
extra_hosts: *default-extra_hosts
container_name: openchurch_backend_cli
Expand All @@ -91,11 +92,17 @@ services:
ELASTIC_PASSWORD: admin
SYNCHRO_SECRET_KEY: secret
REDIS_URL: redis://redis:6379
ROLE: cli
depends_on:
- db
- redis
- elasticsearch
user: root
healthcheck:
test: if [ $$(pgrep -F /var/run/crond.pid -r S,R --count) -eq 1 ]; then exit 0; else exit 1; fi
interval: 5s
timeout: 5s
retries: 55
networks:
- app-network
python:
Expand Down
16 changes: 13 additions & 3 deletions usr/local/bin/docker-php-entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ if [[ ! "$@" == *"frankenphp"* ]] || [ "$APP_ENV" != "prod" ]; then
sleep 10
fi
echo "\n db is UP!"

# Run database migrations
# bin/console -n doctrine:migrations:migrate -vvv
fi

nice php -d memory_limit=256M bin/console -n cache:clear --no-warmup
Expand All @@ -88,4 +85,17 @@ nice php -d memory_limit=256M bin/console -n cache:warmup
# Restore correct access rights to all project files exept for node_modules and vendor (they are not writable and do not belong to us):
chown -R www-data:www-data $(ls -A1 | grep -Ev 'vendor|node_modules|.git')

if [ "$ROLE" == 'cli' ]; then
# Run database migrations
bin/console -n doctrine:migrations:migrate -vvv

# Merge docker env variables and cron.d/rosario
env > /etc/cron.d/openchurch_env
cat /etc/cron.d/backend >> /etc/cron.d/openchurch_env
mv /etc/cron.d/openchurch_env /etc/cron.d/backend

# Initialize elastic indexes
bin/console -vvv app:write:indexes
fi

exec "$@"
8 changes: 5 additions & 3 deletions usr/local/bin/docker-python-entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ set -e
env > /etc/environment
echo -------------------; echo Versions: ; python --version ; pip --version ; echo -------------------

/opt/venv/bin/python /app/synchro.py --entity-only diocese &&
/opt/venv/bin/python /app/synchro.py --entity-only parish &&
/opt/venv/bin/python /app/synchro.py --entity-only church
while true; do
/opt/venv/bin/python /app/synchro.py --entity-only diocese
/opt/venv/bin/python /app/synchro.py --entity-only parish
/opt/venv/bin/python /app/synchro.py --entity-only church
done

exec "$@"

0 comments on commit 8e6ae66

Please sign in to comment.