From 738d20356c9e0abc87585d360e6b7863712e3e93 Mon Sep 17 00:00:00 2001 From: turegjorup Date: Wed, 4 Dec 2024 14:13:50 +0100 Subject: [PATCH 1/6] 3136: Updated ITK docker setup --- .docker/data/.gitignore | 5 +++ .docker/data/README.md | 26 +++++++++++ .docker/nginx.conf | 9 ++-- .docker/templates/default.conf.template | 60 +++++++++++++++++++++++++ docker-compose.dev.yml | 25 +++++------ docker-compose.redirect.yml | 4 +- docker-compose.server.yml | 15 ++++--- docker-compose.yml | 35 ++++++++++----- 8 files changed, 139 insertions(+), 40 deletions(-) create mode 100644 .docker/data/.gitignore create mode 100644 .docker/data/README.md create mode 100644 .docker/templates/default.conf.template diff --git a/.docker/data/.gitignore b/.docker/data/.gitignore new file mode 100644 index 0000000..80a9dc9 --- /dev/null +++ b/.docker/data/.gitignore @@ -0,0 +1,5 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore +!Readme.md diff --git a/.docker/data/README.md b/.docker/data/README.md new file mode 100644 index 0000000..8895d7b --- /dev/null +++ b/.docker/data/README.md @@ -0,0 +1,26 @@ +# .docker/data + +Please map persistent volumes to this directory on the servers. + +If a container needs to persist data between restarts you can map the relevant files in the container to ``docker/data/`. + +## RabbitMQ example +If you are using RabbitMQ running in a container as a message broker you need to configure a persistent volume for RabbitMQs data directory to avoid losing message on container restarts. + +```yaml +# docker-compose.server.override.yml + +services: + rabbit: + image: rabbitmq:3.9-management-alpine + hostname: "${COMPOSE_PROJECT_NAME}" + networks: + - app + - frontend + environment: + - "RABBITMQ_DEFAULT_USER=${RABBITMQ_USER}" + - "RABBITMQ_DEFAULT_PASS=${RABBITMQ_PASSWORD}" + - "RABBITMQ_ERLANG_COOKIE=${RABBITMQ_ERLANG_COOKIE}" + volumes: + - ".docker/data/rabbitmq:/var/lib/rabbitmq/mnesia/" +``` diff --git a/.docker/nginx.conf b/.docker/nginx.conf index 43dbd19..8fe03db 100644 --- a/.docker/nginx.conf +++ b/.docker/nginx.conf @@ -1,13 +1,12 @@ worker_processes auto; -error_log /var/log/nginx/error.log notice; +error_log /dev/stderr notice; pid /tmp/nginx.pid; events { worker_connections 1024; } - http { proxy_temp_path /tmp/proxy_temp; client_body_temp_path /tmp/client_temp; @@ -18,7 +17,7 @@ http { include /etc/nginx/mime.types; default_type application/octet-stream; - set_real_ip_from 172.16.0.0/8; + set_real_ip_from 172.16.0.0/16; real_ip_recursive on; real_ip_header X-Forwarded-For; @@ -26,11 +25,9 @@ http { '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; - access_log /var/log/nginx/access.log main; + access_log /dev/stdout main; sendfile on; - #tcp_nopush on; - keepalive_timeout 65; gzip on; diff --git a/.docker/templates/default.conf.template b/.docker/templates/default.conf.template new file mode 100644 index 0000000..2f6f7c3 --- /dev/null +++ b/.docker/templates/default.conf.template @@ -0,0 +1,60 @@ +server { + listen ${NGINX_PORT}; + server_name localhost; + + root ${NGINX_WEB_ROOT}; + + client_max_body_size ${NGINX_MAX_BODY_SIZE}; + + # This also needs to be set in the single server tag and not only in http. + set_real_ip_from 172.16.0.0/16; + real_ip_recursive on; + real_ip_header X-Forwarded-For; + + location / { + # try to serve file directly, fallback to app.php + #try_files $uri /app.php$is_args$args; + try_files $uri /app_dev.php$is_args$args; + } + + # Protect files and directories from prying eyes. + location ~* \.(engine|inc|install|make|module|profile|po|sh|.*sql|.tar|.gz|.bz2|theme|twig|tpl(\.php)?|xtmpl|yml)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\.(?!well-known).*|Entries.*|Repository|Root|Tag|Template|composer\.(json|lock)|web\.config)$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig|\.save)$ { + deny all; + return 404; + } + + # Development + location ~ ^/(app_dev|config)\.php(/|$) { + fastcgi_buffers 16 32k; + fastcgi_buffer_size 64k; + fastcgi_busy_buffers_size 64k; + + fastcgi_pass ${NGINX_FPM_SERVICE}; + fastcgi_split_path_info ^(.+\.php)(/.*)$; + include fastcgi_params; + + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; + fastcgi_param DOCUMENT_ROOT $realpath_root; + } + + # Production + location ~ ^/app\.php(/|$) { + fastcgi_pass ${NGINX_FPM_SERVICE}; + fastcgi_split_path_info ^(.+\.php)(/.*)$; + include fastcgi_params; + + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; + fastcgi_param DOCUMENT_ROOT $realpath_root; + + internal; + } + + + location ~ \.php$ { + return 404; + } + + # Send log message to files symlinked to stdout/stderr. + error_log /dev/stderr; + access_log /dev/stdout main; +} diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 0e734f2..4ac6fe3 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -1,28 +1,27 @@ -# itk-version: 3.0.0 -version: "3" - +# itk-version: 3.2.1 services: phpfpm: environment: - - PHP_SENDMAIL_PATH='/usr/local/bin/mhsendmail --smtp-addr="mailhog:1025"' + - PHP_SENDMAIL_PATH=/usr/sbin/sendmail -S mail:1025 nginx: labels: - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.middlewares=ITKBasicAuth@file" - mailhog: - image: itkdev/mailhog + mail: + image: axllent/mailpit + restart: unless-stopped networks: - app - frontend labels: - "traefik.enable=true" - "traefik.docker.network=frontend" - - "traefik.http.routers.mailhog_${COMPOSE_PROJECT_NAME}-http.rule=Host(`mailhog.${COMPOSE_SERVER_DOMAIN}`)" - - "traefik.http.routers.mailhog_${COMPOSE_PROJECT_NAME}-http.entrypoints=web" - - "traefik.http.routers.mailhog_${COMPOSE_PROJECT_NAME}-http.middlewares=redirect-to-https" + - "traefik.http.routers.mail_${COMPOSE_PROJECT_NAME}-http.rule=Host(`mail.${COMPOSE_SERVER_DOMAIN}`)" + - "traefik.http.routers.mail_${COMPOSE_PROJECT_NAME}-http.entrypoints=web" + - "traefik.http.routers.mail_${COMPOSE_PROJECT_NAME}-http.middlewares=redirect-to-https" - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" - - "traefik.http.routers.mailhog_${COMPOSE_PROJECT_NAME}.rule=Host(`mailhog.${COMPOSE_SERVER_DOMAIN}`)" - - "traefik.http.routers.mailhog_${COMPOSE_PROJECT_NAME}.entrypoints=websecure" - - "traefik.http.services.mailhog_${COMPOSE_PROJECT_NAME}.loadbalancer.server.port=8025" - - "traefik.http.routers.mailhog_${COMPOSE_PROJECT_NAME}.middlewares=ITKMailhogAuth@file" + - "traefik.http.routers.mail_${COMPOSE_PROJECT_NAME}.rule=Host(`mail.${COMPOSE_SERVER_DOMAIN}`)" + - "traefik.http.routers.mail_${COMPOSE_PROJECT_NAME}.entrypoints=websecure" + - "traefik.http.services.mail_${COMPOSE_PROJECT_NAME}.loadbalancer.server.port=8025" + - "traefik.http.routers.mail_${COMPOSE_PROJECT_NAME}.middlewares=ITKMailhogAuth@file" diff --git a/docker-compose.redirect.yml b/docker-compose.redirect.yml index 9c1d2af..66f26e9 100644 --- a/docker-compose.redirect.yml +++ b/docker-compose.redirect.yml @@ -1,6 +1,4 @@ -# itk-version: 3.0.0 -version: "3" - +# itk-version: 3.2.1 services: nginx: labels: diff --git a/docker-compose.server.yml b/docker-compose.server.yml index f29fc6c..04870ee 100644 --- a/docker-compose.server.yml +++ b/docker-compose.server.yml @@ -1,6 +1,4 @@ -# itk-version: 3.0.0 -version: "3" - +# itk-version: 3.2.1 networks: frontend: external: true @@ -31,12 +29,15 @@ services: - frontend depends_on: - phpfpm - ports: - - '8080' volumes: - - ./.docker/vhost.conf:/etc/nginx/conf.d/default.conf:ro + - ./.docker/templates:/etc/nginx/templates:ro - ./.docker/nginx.conf:/etc/nginx/nginx.conf:ro - - ./:/app:rw + - .:/app + environment: + NGINX_FPM_SERVICE: ${COMPOSE_PROJECT_NAME}-phpfpm-1:9000 + NGINX_WEB_ROOT: /app/web + NGINX_PORT: 8080 + NGINX_MAX_BODY_SIZE: 5M labels: - "traefik.enable=true" - "traefik.docker.network=frontend" diff --git a/docker-compose.yml b/docker-compose.yml index 2972519..20f334b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,4 @@ -# itk-version: 3.0.0 -version: "3" - +# itk-version: 3.2.1 networks: frontend: external: true @@ -15,6 +13,12 @@ services: - app ports: - '3306' + healthcheck: + test: [ "CMD", "healthcheck.sh", "--connect", "--innodb_initialized" ] + start_period: 10s + interval: 10s + timeout: 5s + retries: 3 environment: - MYSQL_ROOT_PASSWORD=password - MYSQL_USER=db @@ -29,16 +33,20 @@ services: image: itkdev/php7.2-fpm:latest networks: - app + extra_hosts: + - "host.docker.internal:host-gateway" environment: - PHP_XDEBUG_REMOTE_ENABLE=${PHP_XDEBUG_REMOTE_ENABLE:-0} - PHP_MAX_EXECUTION_TIME=30 - PHP_MEMORY_LIMIT=256M - # - PHP_MAIL=1 # Uncomment to enable mailhog. + # Depending on the setup, you may have to remove --read-envelope-from from msmtp (cf. https://marlam.de/msmtp/msmtp.html) or use SMTP to send mail + - PHP_SENDMAIL_PATH=/usr/bin/msmtp --host=mail --port=1025 --read-recipients --read-envelope-from - DOCKER_HOST_DOMAIN=${COMPOSE_DOMAIN} - - COMPOSER_VERSION=1 + - COMPOSER_VERSION=2 - PHP_IDE_CONFIG=serverName=localhost depends_on: - - mariadb + mariadb: + condition: service_healthy volumes: - .:/app @@ -52,8 +60,13 @@ services: ports: - '8080' volumes: - - ./.docker/vhost.conf:/etc/nginx/conf.d/default.conf:ro + - ./.docker/templates:/etc/nginx/templates:ro - .:/app + environment: + NGINX_FPM_SERVICE: ${COMPOSE_PROJECT_NAME}-phpfpm-1:9000 + NGINX_WEB_ROOT: /app/web + NGINX_PORT: 8080 + NGINX_MAX_BODY_SIZE: 5M labels: - "traefik.enable=true" - "traefik.docker.network=frontend" @@ -62,8 +75,8 @@ services: # - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.middlewares=redirect-to-https" # - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" - mailhog: - image: itkdev/mailhog + mail: + image: axllent/mailpit networks: - app - frontend @@ -73,5 +86,5 @@ services: labels: - "traefik.enable=true" - "traefik.docker.network=frontend" - - "traefik.http.routers.${COMPOSE_PROJECT_NAME}Mailhog.rule=Host(`mailhog-${COMPOSE_DOMAIN}`)" - - "traefik.http.services.${COMPOSE_PROJECT_NAME}Mailhog.loadbalancer.server.port=8025" + - "traefik.http.routers.${COMPOSE_PROJECT_NAME}mail.rule=Host(`mail-${COMPOSE_DOMAIN}`)" + - "traefik.http.services.${COMPOSE_PROJECT_NAME}mail.loadbalancer.server.port=8025" From a596ecde0168d946642bef997566bdf4f2b4c899 Mon Sep 17 00:00:00 2001 From: turegjorup Date: Wed, 4 Dec 2024 14:14:24 +0100 Subject: [PATCH 2/6] 3136: Added v1 prefix to all routes except api --- app/config/routing.yml | 8 +++++--- app/config/routing_dev.yml | 6 +++--- src/AdminBundle/Action/DefaultAction.php | 2 +- src/AdminBundle/Action/ResourceAction.php | 2 +- src/AdminBundle/Controller/EditorController.php | 2 +- src/AdminBundle/Controller/FeedController.php | 2 +- src/AdminBundle/Controller/HelperController.php | 2 +- src/AdminBundle/Controller/LoggableController.php | 2 +- src/AdminBundle/Controller/TagController.php | 2 +- src/AdminBundle/Controller/UnknownTagController.php | 2 +- src/AdminBundle/Controller/UserController.php | 2 +- 11 files changed, 17 insertions(+), 15 deletions(-) diff --git a/app/config/routing.yml b/app/config/routing.yml index 65f6049..7855829 100644 --- a/app/config/routing.yml +++ b/app/config/routing.yml @@ -23,19 +23,21 @@ admin: fos_user: resource: '@FOSUserBundle/Resources/config/routing/all.xml' + prefix: /v1 fos_user_group: resource: '@FOSUserBundle/Resources/config/routing/group.xml' - prefix: /group + prefix: /v1/group easy_admin_bundle: resource: '@AdminBundle/Controller/AdminController.php' type: annotation - prefix: /easyadmin + prefix: /v1/easyadmin liip_imagine: resource: '@LiipImagineBundle/Resources/config/routing.yaml' + prefix: /v1 terms_bundle: resource: '@ItkDevTermsBundle/Resources/config/routing.xml' - prefix: /terms + prefix: /v1/terms diff --git a/app/config/routing_dev.yml b/app/config/routing_dev.yml index 20602eb..6622e90 100644 --- a/app/config/routing_dev.yml +++ b/app/config/routing_dev.yml @@ -1,14 +1,14 @@ _wdt: resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml' - prefix: /_wdt + prefix: /v1/_wdt _profiler: resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml' - prefix: /_profiler + prefix: /v1/_profiler _errors: resource: '@TwigBundle/Resources/config/routing/errors.xml' - prefix: /_error + prefix: /v1/_error _main: resource: routing.yml diff --git a/src/AdminBundle/Action/DefaultAction.php b/src/AdminBundle/Action/DefaultAction.php index 5383416..0b9e7f0 100644 --- a/src/AdminBundle/Action/DefaultAction.php +++ b/src/AdminBundle/Action/DefaultAction.php @@ -35,7 +35,7 @@ public function __construct(RouterInterface $router, \Twig_Environment $twig) } /** - * @Route("/", name="default") + * @Route("/v1", name="default") * * Using annotations is not mandatory, XML and YAML configuration files can be used instead. * If you want to decouple your actions from the framework, don't use annotations. diff --git a/src/AdminBundle/Action/ResourceAction.php b/src/AdminBundle/Action/ResourceAction.php index 8ec2ede..e5544ec 100644 --- a/src/AdminBundle/Action/ResourceAction.php +++ b/src/AdminBundle/Action/ResourceAction.php @@ -45,7 +45,7 @@ public function __construct(RouterInterface $router, ContainerInterface $contain } /** - * @Route("/resource/", name="resource") + * @Route("/v1/resource/", name="resource") * * Using annotations is not mandatory, XML and YAML configuration files can be used instead. * If you want to decouple your actions from the framework, don't use annotations. diff --git a/src/AdminBundle/Controller/EditorController.php b/src/AdminBundle/Controller/EditorController.php index 9ee412e..29555a1 100644 --- a/src/AdminBundle/Controller/EditorController.php +++ b/src/AdminBundle/Controller/EditorController.php @@ -19,7 +19,7 @@ /** * Editor/SPA controller. * - * @Route("/editor") + * @Route("/v1/editor") * @Security("has_role('ROLE_EVENT_EDITOR')") */ class EditorController extends Controller diff --git a/src/AdminBundle/Controller/FeedController.php b/src/AdminBundle/Controller/FeedController.php index d1a6900..2c331f3 100644 --- a/src/AdminBundle/Controller/FeedController.php +++ b/src/AdminBundle/Controller/FeedController.php @@ -21,7 +21,7 @@ /** * Feed controller. * - * @Route("/admin/feed") + * @Route("/v1/admin/feed") * @Security("has_role('ROLE_FEED_EDITOR')") */ class FeedController extends Controller diff --git a/src/AdminBundle/Controller/HelperController.php b/src/AdminBundle/Controller/HelperController.php index 38d8d2c..23e7148 100644 --- a/src/AdminBundle/Controller/HelperController.php +++ b/src/AdminBundle/Controller/HelperController.php @@ -17,7 +17,7 @@ /** * Helper controller. * - * @Route("/helper") + * @Route("/v1/helper") */ class HelperController extends Controller { diff --git a/src/AdminBundle/Controller/LoggableController.php b/src/AdminBundle/Controller/LoggableController.php index 19621cb..c798290 100644 --- a/src/AdminBundle/Controller/LoggableController.php +++ b/src/AdminBundle/Controller/LoggableController.php @@ -24,7 +24,7 @@ /** * Loggable controller. * - * @Route("/admin/loggable/{entityType}") + * @Route("/v1/admin/loggable/{entityType}") * @Security("has_role('ROLE_SUPER_ADMIN')") */ class LoggableController extends Controller diff --git a/src/AdminBundle/Controller/TagController.php b/src/AdminBundle/Controller/TagController.php index 75e76bd..45a7d82 100644 --- a/src/AdminBundle/Controller/TagController.php +++ b/src/AdminBundle/Controller/TagController.php @@ -21,7 +21,7 @@ /** * Tag controller. * - * @Route("/admin/tag") + * @Route("/v1/admin/tag") * @Security("has_role('ROLE_TAG_EDITOR')") */ class TagController extends Controller diff --git a/src/AdminBundle/Controller/UnknownTagController.php b/src/AdminBundle/Controller/UnknownTagController.php index 7261c9c..7b3fd8b 100644 --- a/src/AdminBundle/Controller/UnknownTagController.php +++ b/src/AdminBundle/Controller/UnknownTagController.php @@ -21,7 +21,7 @@ /** * UnknownTag controller. * - * @Route("/admin/unknown_tag") + * @Route("/v1/admin/unknown_tag") * @Security("has_role('ROLE_TAG_EDITOR')") */ class UnknownTagController extends Controller diff --git a/src/AdminBundle/Controller/UserController.php b/src/AdminBundle/Controller/UserController.php index c89ad30..7fba5b3 100644 --- a/src/AdminBundle/Controller/UserController.php +++ b/src/AdminBundle/Controller/UserController.php @@ -20,7 +20,7 @@ /** * User controller. * - * @Route("/admin/user") + * @Route("/v1/admin/user") * @Security("has_role('ROLE_USER_EDITOR')") */ class UserController extends Controller From 86f55a5970ddc37184b9d7f57476ac6c209ed53c Mon Sep 17 00:00:00 2001 From: turegjorup Date: Wed, 4 Dec 2024 15:49:02 +0100 Subject: [PATCH 3/6] 3136: Added v1 prefix for bundle assets, fix path prefix for login --- .docker/templates/default.conf.template | 8 ++++++-- app/config/config.yml | 3 ++- app/config/security.yml | 17 ++++++++++------- docker-compose.override.yml | 9 +++++++++ docker-compose.server.override.yml | 9 +++++++++ 5 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 docker-compose.override.yml create mode 100644 docker-compose.server.override.yml diff --git a/.docker/templates/default.conf.template b/.docker/templates/default.conf.template index 2f6f7c3..f1a5f24 100644 --- a/.docker/templates/default.conf.template +++ b/.docker/templates/default.conf.template @@ -12,8 +12,12 @@ server { real_ip_header X-Forwarded-For; location / { - # try to serve file directly, fallback to app.php - #try_files $uri /app.php$is_args$args; + # We are co-hosting with the legacy EventDB, so this app is hosted under '/v1' + # This is configured for Symfony in 'framework.assets.base_path'. However + # Symfony still installs assets in the root path so we need to rewrite the uri to remove '/v1'. + rewrite ^/v1/bundles/(.*) /bundles/$1 break; + + # try to serve file directly, fallback to index.php try_files $uri /app_dev.php$is_args$args; } diff --git a/app/config/config.yml b/app/config/config.yml index a7ebbb6..83bc884 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -30,7 +30,8 @@ framework: handler_id: ~ fragments: ~ http_method_override: true - assets: ~ + assets: + base_path: '/v1' property_info: enabled: true diff --git a/app/config/security.yml b/app/config/security.yml index 64d06e4..4205e88 100644 --- a/app/config/security.yml +++ b/app/config/security.yml @@ -58,13 +58,16 @@ security: # http://symfony.com/doc/current/cookbook/security/form_login_setup.html # form_login: - pattern: ^/ + pattern: ^/v1 form_login: provider: fos_userbundle check_path: fos_user_security_check login_path: fos_user_security_login + default_target_path: default # csrf_provider: security.csrf.token_manager - logout: true + logout: + path: fos_user_security_logout + target: default logout_on_user_change: true access_control: @@ -75,8 +78,8 @@ security: # Read only API access - { path: ^/api, roles: [IS_AUTHENTICATED_ANONYMOUSLY] } - - { path: ^/login, role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: ^/admin, role: ROLE_USER } - - { path: ^/easyadmin, role: ROLE_USER } + - { path: ^/v1/login, role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: ^/v1/register, role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: ^/v1/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: ^/v1/admin, role: ROLE_USER } + - { path: ^/v1/easyadmin, role: ROLE_USER } diff --git a/docker-compose.override.yml b/docker-compose.override.yml new file mode 100644 index 0000000..910ac43 --- /dev/null +++ b/docker-compose.override.yml @@ -0,0 +1,9 @@ +# itk-version: 3.2.1 +services: + nginx: + labels: + # Scope hosting by path prefix to allow shared hosting with EventDB v2 + # 'https://api.detskeriaarhus.dk/v1/' -> Legacy EventDB (v1) + # 'https://api.detskeriaarhus.dk/api/' -> Legacy EventDB API (v1) + - "traefik.http.routers.${COMPOSE_PROJECT_NAME}-http.rule=Host(`${COMPOSE_DOMAIN}`) && (PathPrefix(`/v1`) || PathPrefix(`/api`))" + - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.rule=Host(`${COMPOSE_DOMAIN}`) && (PathPrefix(`/v1`) || PathPrefix(`/api`))" diff --git a/docker-compose.server.override.yml b/docker-compose.server.override.yml new file mode 100644 index 0000000..8dbe97f --- /dev/null +++ b/docker-compose.server.override.yml @@ -0,0 +1,9 @@ +# itk-version: 3.2.1 +services: + nginx: + labels: + # Scope hosting by path prefix to allow shared hosting with EventDB v2 + # 'https://api.detskeriaarhus.dk/v1/' -> Legacy EventDB (v1) + # 'https://api.detskeriaarhus.dk/api/' -> Legacy EventDB API (v1) + - "traefik.http.routers.${COMPOSE_PROJECT_NAME}-http.rule=Host(`${COMPOSE_SERVER_DOMAIN}`) && (PathPrefix(`/v1`) || PathPrefix(`/api`))" + - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.rule=Host(`${COMPOSE_SERVER_DOMAIN}`) && (PathPrefix(`/v1`) || PathPrefix(`/api`))" \ No newline at end of file From 003612ba166ea5766c6e4bd372a19b0319351d0c Mon Sep 17 00:00:00 2001 From: turegjorup Date: Wed, 4 Dec 2024 15:50:25 +0100 Subject: [PATCH 4/6] 3136: Added delete events command --- .../Command/DeleteEventsCommand.php | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 src/AdminBundle/Command/DeleteEventsCommand.php diff --git a/src/AdminBundle/Command/DeleteEventsCommand.php b/src/AdminBundle/Command/DeleteEventsCommand.php new file mode 100644 index 0000000..6815d49 --- /dev/null +++ b/src/AdminBundle/Command/DeleteEventsCommand.php @@ -0,0 +1,85 @@ +setName('app:event:delete') + ->setDescription('Delete all events from feed') + ->addArgument('feed-id', InputOption::VALUE_REQUIRED, 'Feed ID') + ->addArgument('username', InputOption::VALUE_REQUIRED, 'Username to run command as'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $em = $this->getContainer()->get('doctrine.orm.entity_manager'); + $user = $em->getRepository('AppBundle:User')->findOneByUsername($input->getArgument('username')); + + if (!$user) { + $output->writeln('Username not found'); + + return -1; + } + + // Fake a user to satisfy "isGranted" calls in doctrine listeners + $token = new UsernamePasswordToken( + $user, + null, + 'main', + $user->getRoles() + ); + $this->getContainer()->get('security.token_storage')->setToken($token); + + $feedId = $input->getArgument('feed-id'); + + $count = $em->createQueryBuilder() + ->select('count(e.id)') + ->from('AppBundle:Event', 'e') + ->where('e.feed = :feedId') + ->setParameter('feedId', $feedId) + ->getQuery() + ->getSingleScalarResult(); + + $iterableResult = $em->createQueryBuilder() + ->select('e') + ->from('AppBundle:Event', 'e') + ->where('e.feed = :feedId') + ->setParameter('feedId', $feedId) + ->getQuery() + ->iterate(); + + $progressBar = new ProgressBar($output, $count); + $progressBar->setFormat('debug'); + $progressBar->start(); + + foreach ($iterableResult as $row) { + $event = $row[0]; + + $em->remove($event); + $em->flush(); + $em->clear(); + + $progressBar->advance(); + } + + $progressBar->finish(); + } +} From 298e5e06bfb689eb44182b66475137c770c7c48c Mon Sep 17 00:00:00 2001 From: turegjorup Date: Wed, 4 Dec 2024 15:53:28 +0100 Subject: [PATCH 5/6] 3136: Update Readme --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index ba0f5a7..3c53e7b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ +# Archived dec. 2024 +Project is archived and unmaintained. Please see: +* https://github.com/itk-dev/event-database-imports +* https://github.com/itk-dev/event-database-api + Event database – the API ======================== From 1f8b3814a1073281452cf8c23a18cc03dd0743f3 Mon Sep 17 00:00:00 2001 From: turegjorup Date: Wed, 4 Dec 2024 15:58:28 +0100 Subject: [PATCH 6/6] 3136: Cleanup --- .docker/vhost.conf | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 .docker/vhost.conf diff --git a/.docker/vhost.conf b/.docker/vhost.conf deleted file mode 100644 index 933bfa5..0000000 --- a/.docker/vhost.conf +++ /dev/null @@ -1,46 +0,0 @@ -server { - listen 8080; - server_name localhost; - root /app/web; - - location / { - # try to serve file directly, fallback to app.php - #try_files $uri /app.php$is_args$args; - try_files $uri /app_dev.php$is_args$args; - } - - # Development - location ~ ^/(app_dev|config)\.php(/|$) { - fastcgi_buffers 16 32k; - fastcgi_buffer_size 64k; - fastcgi_busy_buffers_size 64k; - - fastcgi_pass phpfpm:9000; - fastcgi_split_path_info ^(.+\.php)(/.*)$; - include fastcgi_params; - - fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; - fastcgi_param DOCUMENT_ROOT $realpath_root; - } - - # Production - location ~ ^/app\.php(/|$) { - fastcgi_pass phpfpm:9000; - fastcgi_split_path_info ^(.+\.php)(/.*)$; - include fastcgi_params; - - fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; - fastcgi_param DOCUMENT_ROOT $realpath_root; - - internal; - } - - - location ~ \.php$ { - return 404; - } - - # Send log message to files symlinked to stdout/stderr. - error_log /dev/stderr; - access_log /dev/stdout main; -}