Skip to content

Commit 6597e6e

Browse files
committed
wip
1 parent c02c65e commit 6597e6e

10 files changed

+80
-76
lines changed

.env

-7
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,5 @@ MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
77
LOCK_DSN=flock
88
CORS_ALLOW_ORIGIN='^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$'
99

10-
###> synchro scripts ###
11-
SQLITE_DATABASE=local.sqlite
12-
OPENCHURCH_HOST='https://api.openchurch.local/api'
13-
OPENCHURCH_API_TOKEN='giergij'
14-
PYTHONWARNINGS="ignore:Unverified HTTPS request"
15-
###< synchro scripts ###
16-
1710
ELASTIC_PASSWORD=admin
1811
ELASTICSEARCH_IRI=https://elastic:admin@elasticsearch:9200

.env.test

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
# define your env variables for the test env here
2-
KERNEL_CLASS='App\Kernel'
3-
APP_SECRET='$ecretf0rt3st'
4-
SYMFONY_DEPRECATIONS_HELPER=999999
5-
PANTHER_APP_ENV=panther
6-
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
72
APP_ENV=test
3+
APP_SECRET='$ecretf0rt3st'

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
1. Attention à la création des communautés / places !
22
Les fields et leurs entités doivent être persistés ensemble avant de flush
33
2. Comme nous n'avons pas encore de moyens de supprimer des entités (depuis endpoint ou admin), la synchro elastic pour la suppression n'a pas encore été implémentée
4+
5+
### Script
6+
7+
Load data from Wikidata: python3 synchro.py
8+
Push data to OpenChurch v2: python3 synchro.py push
9+
Print statistics: python3 synchro.py stats
10+
11+
The local.sqlite serves as a local buffer to store the OpenChurch v2 UUIDs and remember what as already been pushed, what has not and determine what has been updated on Wikidata since the last push.
12+
13+
1st run is very long (several hours) because it loads places (cities, countries) from Wikidata. It is recommended to put the attached SQLite database in the scripts folder to fasten the process. Every data from this file (except OpenChurch UUIDs) is from Wikidata with license is CC0.
14+
local.sqlite.gz

compose.override.yaml

-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
services:
2-
###> doctrine/doctrine-bundle ###
32
db:
43
ports:
54
- "3306:3306"
6-
###< doctrine/doctrine-bundle ###
7-
8-
###> symfony/mailer ###
9-
10-
###< symfony/mailer ###

compose.yaml

+5-9
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,15 @@ services:
6767
build:
6868
context: .
6969
dockerfile: ./docker/python/Dockerfile
70-
volumes:
71-
- ./scripts:/app
72-
- ./.env:/app/.env
73-
entrypoint: ["sh", "/usr/local/bin/docker-python-entrypoint"]
74-
command: ["/bin/sh"]
75-
tty: true
76-
stdin_open: true
7770
networks:
7871
- app-network
7972
extra_hosts:
8073
- "api.openchurch.local:host-gateway"
81-
depends_on:
82-
- backend
74+
environment:
75+
SQLITE_DATABASE: local.sqlite
76+
OPENCHURCH_HOST: "https://api.openchurch.local/api"
77+
OPENCHURCH_API_TOKEN: "fake_token"
78+
PYTHONWARNINGS: "ignore:Unverified HTTPS request"
8379

8480
volumes:
8581
openchurch_db_data: {}

docker/php/Dockerfile

+5-27
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,19 @@ FROM dunglas/frankenphp
22
LABEL org.opencontainers.image.authors="[email protected]"
33

44
ARG USER=www-data
5-
ARG SERVER_NAME=rosario.local
6-
75
WORKDIR /var/www/html
86

97
RUN apt update && apt install -y \
108
acl \
119
autoconf \
1210
cron \
13-
ffmpeg \
14-
gawk \
15-
g++ \
16-
make \
17-
libnss3-tools \
18-
libpng-dev \
19-
libexif-dev \
20-
libxpm-dev \
21-
libxml2-dev \
22-
libxslt-dev \
23-
libwebp-dev \
24-
libzip-dev \
25-
libgmp-dev \
26-
libjpeg-dev \
2711
logrotate \
28-
nodejs \
29-
npm \
3012
sudo \
3113
bash \
3214
procps \
15+
libzip-dev \
16+
libxslt-dev \
17+
libgmp-dev \
3318
&& mkdir -p /var/www/html/var/ \
3419
&& apt clean
3520

@@ -38,14 +23,8 @@ RUN curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php \
3823
&& php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer \
3924
&& rm /tmp/composer-setup.php
4025

41-
RUN docker-php-ext-configure gd --with-jpeg --with-webp \
42-
&& docker-php-ext-configure gmp \
43-
&& docker-php-ext-configure intl
44-
4526
RUN docker-php-ext-install \
4627
pdo_mysql \
47-
gd \
48-
intl \
4928
zip \
5029
exif \
5130
xsl \
@@ -54,10 +33,8 @@ RUN docker-php-ext-install \
5433
gmp
5534

5635
# add PECL extensions
57-
RUN pecl install redis && docker-php-ext-enable redis && \
58-
pecl install apcu && docker-php-ext-enable apcu && \
36+
RUN pecl install apcu && docker-php-ext-enable apcu && \
5937
pecl install xdebug && docker-php-ext-enable xdebug
60-
#pecl install amqp && docker-php-ext-enable amqp && \
6138

6239
COPY src/ /var/www/html/src/
6340
COPY public/ /var/www/html/public/
@@ -72,6 +49,7 @@ COPY symfony.lock /var/www/html/
7249
COPY usr/local/bin/docker-php-entrypoint /usr/local/bin/
7350
COPY .env /var/www/html/
7451
COPY .env.test /var/www/html/
52+
COPY etc/cron.d/backend /etc/cron.d/backend
7553

7654
# The following line is needed only for load tests
7755
COPY tests/ /var/www/html/tests/

docker/python/Dockerfile

+18-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1-
FROM alpine:3.20.3
1+
FROM python:3.9-slim as compiler
2+
ENV PYTHONUNBUFFERED 1
23

3-
WORKDIR /app
4+
WORKDIR /app/
45

5-
RUN apk update && apk add --update --no-cache \
6-
python3 \
7-
py3-pip \
8-
&& ln -sf python3 /usr/bin/python
6+
RUN python -m venv /opt/venv
7+
# Enable venv
8+
ENV PATH="/opt/venv/bin:$PATH"
99

10-
COPY ./usr/local/bin/docker-python-entrypoint /usr/local/bin/
11-
COPY .env /app/
10+
COPY ./scripts/requirements.txt /app/requirements.txt
11+
RUN pip install -Ur requirements.txt
12+
13+
FROM python:3.9-slim as runner
14+
WORKDIR /app/
15+
COPY --from=compiler /opt/venv /opt/venv
16+
17+
# Enable venv
18+
ENV PATH="/opt/venv/bin:$PATH"
19+
COPY ./scripts /app/
20+
21+
ENTRYPOINT ["tail", "-f", "/dev/null"]

etc/cron.d/backend

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
HOME=/var/www/html
2+
LANG=nb_NO.UTF-8
3+
LC_ALL=nb_NO.UTF-8
4+
5+
# Each task to run has to be defined through a single line
6+
# indicating with different fields when the task will be run
7+
# and what command to run for the task
8+
#
9+
# To define the time you can provide concrete values for
10+
# minute (m), hour (h), day of month (dom), month (mon),
11+
# and day of week (dow) or use '*' in these fields (for 'any').
12+
#
13+
# Notice that tasks will be started based on the cron's system
14+
# daemon's notion of time and timezones.
15+
#
16+
# Output of the crontab jobs (including errors) is sent through
17+
# email to the user the crontab file belongs to (unless redirected).
18+
#
19+
# For example, you can run a backup of all your user accounts
20+
# at 5 a.m every week with:
21+
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
22+
#
23+
# For more information see the manual pages of crontab(5) and cron(8)
24+
#
25+
# m h dom mon dow command
26+
27+
# 0 0 * * * root test ! -f $HOME/deploying.lock && /usr/local/bin/php $HOME/bin/console app:cron:delete-expired-refresh-tokens > /proc/1/fd/1 2>/proc/1/fd/2
28+
# 0 3 * * * root test ! -f $HOME/deploying.lock && /usr/local/bin/php $HOME/bin/console app:cron:clean-volatile-streams > /proc/1/fd/1 2>/proc/1/fd/2
29+
# 0 0 * * * root test ! -f $HOME/deploying.lock && /usr/local/bin/php $HOME/bin/console app:cron:delete-accounts > /proc/1/fd/1 2>/proc/1/fd/2
30+
# 0 * * * * root test ! -f $HOME/deploying.lock && /usr/local/bin/php $HOME/bin/console app:cron:set-chapelets-as-over > /proc/1/fd/1 2>/proc/1/fd/2
31+
# 0 3 * * * root test ! -f $HOME/deploying.lock && /usr/local/bin/php $HOME/bin/console app:cron:update-chapelets-activity-score > /proc/1/fd/1 2>/proc/1/fd/2
32+
# 0 6 * * * root test ! -f $HOME/deploying.lock && /usr/local/bin/php $HOME/bin/console app:cron:send-onboarding-push-notifications > /proc/1/fd/1 2>/proc/1/fd/2
33+
# 0 8 * * * root test ! -f $HOME/deploying.lock && /usr/local/bin/php $HOME/bin/console app:cron:inactivity > /proc/1/fd/1 2>/proc/1/fd/2
34+
# * * * * * root test ! -f $HOME/deploying.lock && /usr/local/bin/php $HOME/bin/console app:cron:send-announcements > /proc/1/fd/1 2>/proc/1/fd/2
35+
# * * * * * root test ! -f $HOME/deploying.lock && /usr/local/bin/php $HOME/bin/console app:cron:send-scheduled-push-notifications > /proc/1/fd/1 2>/proc/1/fd/2
36+
# 0 5 * * * root test ! -f $HOME/deploying.lock && /usr/local/bin/php $HOME/bin/console app:cron:chapelet:defragmenter > /proc/1/fd/1 2>/proc/1/fd/2
37+
# 0 18 * * * root test ! -f $HOME/deploying.lock && /usr/local/bin/php $HOME/bin/console app:cron:message:send-digest > /proc/1/fd/1 2>/proc/1/fd/2
38+
# 0 * * * * root test ! -f $HOME/deploying.lock && /usr/bin/php $HOME/bin/console app:cron:import-adjust-events > /proc/1/fd/1 2>/proc/1/fd/2
39+
# 0 0 * * * root /usr/sbin/logrotate -v -d > /proc/1/fd/1 2>/proc/1/fd/2

usr/local/bin/docker-php-entrypoint

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ echo "PHP --> "$(php -v | grep -Eo "PHP [0-9\.]+" | sed 's/PHP //')
1111
echo "Composer --> "$(composer --version | grep -o '\d.\d.\d ')
1212

1313
if [ "$APP_ENV" != 'prod' ]; then
14-
# Install dev convinience tools
14+
# Install dev convenience tools
1515
if [ -z "$(which mycli)" ]; then
1616
apt update && apt install -y mycli inetutils-telnet zip
1717
fi

usr/local/bin/docker-python-entrypoint

-13
This file was deleted.

0 commit comments

Comments
 (0)