Skip to content

Commit 8e6ae66

Browse files
committed
polish containers
1 parent a65af9a commit 8e6ae66

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

compose.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ services:
7272
ELASTIC_PASSWORD: admin
7373
ELASTICSEARCH_IRI: http://elastic:admin@elasticsearch:9200
7474
SYNCHRO_SECRET_KEY: "secret"
75+
ROLE: api
7576
cli:
7677
extra_hosts: *default-extra_hosts
7778
container_name: openchurch_backend_cli
@@ -91,11 +92,17 @@ services:
9192
ELASTIC_PASSWORD: admin
9293
SYNCHRO_SECRET_KEY: secret
9394
REDIS_URL: redis://redis:6379
95+
ROLE: cli
9496
depends_on:
9597
- db
9698
- redis
9799
- elasticsearch
98100
user: root
101+
healthcheck:
102+
test: if [ $$(pgrep -F /var/run/crond.pid -r S,R --count) -eq 1 ]; then exit 0; else exit 1; fi
103+
interval: 5s
104+
timeout: 5s
105+
retries: 55
99106
networks:
100107
- app-network
101108
python:

usr/local/bin/docker-php-entrypoint

+13-3
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ if [[ ! "$@" == *"frankenphp"* ]] || [ "$APP_ENV" != "prod" ]; then
7777
sleep 10
7878
fi
7979
echo "\n db is UP!"
80-
81-
# Run database migrations
82-
# bin/console -n doctrine:migrations:migrate -vvv
8380
fi
8481

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

88+
if [ "$ROLE" == 'cli' ]; then
89+
# Run database migrations
90+
bin/console -n doctrine:migrations:migrate -vvv
91+
92+
# Merge docker env variables and cron.d/rosario
93+
env > /etc/cron.d/openchurch_env
94+
cat /etc/cron.d/backend >> /etc/cron.d/openchurch_env
95+
mv /etc/cron.d/openchurch_env /etc/cron.d/backend
96+
97+
# Initialize elastic indexes
98+
bin/console -vvv app:write:indexes
99+
fi
100+
91101
exec "$@"

usr/local/bin/docker-python-entrypoint

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ set -e
44
env > /etc/environment
55
echo -------------------; echo Versions: ; python --version ; pip --version ; echo -------------------
66

7-
/opt/venv/bin/python /app/synchro.py --entity-only diocese &&
8-
/opt/venv/bin/python /app/synchro.py --entity-only parish &&
9-
/opt/venv/bin/python /app/synchro.py --entity-only church
7+
while true; do
8+
/opt/venv/bin/python /app/synchro.py --entity-only diocese
9+
/opt/venv/bin/python /app/synchro.py --entity-only parish
10+
/opt/venv/bin/python /app/synchro.py --entity-only church
11+
done
1012

1113
exec "$@"

0 commit comments

Comments
 (0)