API & consumers now are executed using docker

This commit is contained in:
theUniC
2022-03-09 19:10:21 +01:00
parent e22de1218f
commit 329060db0e
6 changed files with 121 additions and 13 deletions

View File

@@ -0,0 +1,9 @@
FROM php:8.1-cli
RUN apt-get update \
&& apt-get -y install librabbitmq-dev \
$PHPIZE_DEPS \
&& docker-php-ext-install pdo_mysql mysqli pcntl \
&& pecl install redis \
&& pecl install amqp \
&& docker-php-ext-enable redis amqp

View File

@@ -14,10 +14,12 @@ SHELL := bash
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
DOCKER = $(shell which docker)
# Shortcut for docker-compose command
# Shortcuts
DOCKER = $(shell which docker)
DOCKER_COMPOSE = $(DOCKER) compose
HTTPIE = docker run --network=host -ti --rm alpine/httpie
PHP = $(DOCKER_COMPOSE) exec app php
# Default target when run with just 'make'
default: start
@@ -25,19 +27,18 @@ default: start
.PHONY: start
start:
$(DOCKER_COMPOSE) up -d --remove-orphans
symfony serve -d --no-tls
.PHONY: infrastructure
infrastructure:
redis-cli flushall
http --auth guest:guest DELETE http://localhost:15672/api/queues/%2F/events/contents
http --auth guest:guest DELETE http://localhost:15672/api/queues/%2F/commands/contents
http --auth guest:guest DELETE http://localhost:15672/api/queues/%2F/projections/contents
http --auth guest:guest DELETE http://localhost:15672/api/queues/%2F/failed_messages/contents
php bin/console doc:sch:drop --force
php bin/console doc:sch:create
$(DOCKER_COMPOSE) exec redis redis-cli flushall
$(HTTPIE) --auth guest:guest DELETE http://localhost:15672/api/queues/%2F/events/contents
$(HTTPIE) --auth guest:guest DELETE http://localhost:15672/api/queues/%2F/commands/contents
$(HTTPIE) --auth guest:guest DELETE http://localhost:15672/api/queues/%2F/projections/contents
$(HTTPIE) --auth guest:guest DELETE http://localhost:15672/api/queues/%2F/failed_messages/contents
$(PHP) bin/console doc:sch:drop --force
$(PHP) bin/console doc:sch:create
$(PHP) bin/console messenger:setup-transports
.PHONY: stop
stop:
$(DOCKER_COMPOSE) stop
symfony server:stop
$(DOCKER_COMPOSE) stop

View File

@@ -18,6 +18,7 @@
"ramsey/uuid": "^4.0",
"ramsey/uuid-doctrine": "^1.6",
"snc/redis-bundle": "^4.0",
"symfony/amqp-messenger": "6.0.*",
"symfony/apache-pack": "^1.0",
"symfony/asset": "6.0.*",
"symfony/console": "6.0.*",

71
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "4981dd3569bc0932ba4332ad6566e286",
"content-hash": "0d7c626b3265b177be533cc7e54b0161",
"packages": [
{
"name": "api-platform/core",
@@ -2667,6 +2667,75 @@
},
"time": "2022-03-05T09:40:24+00:00"
},
{
"name": "symfony/amqp-messenger",
"version": "v6.0.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/amqp-messenger.git",
"reference": "fd01ff7e526a9bb87e8c7ba72cbb43750dfafe21"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/amqp-messenger/zipball/fd01ff7e526a9bb87e8c7ba72cbb43750dfafe21",
"reference": "fd01ff7e526a9bb87e8c7ba72cbb43750dfafe21",
"shasum": ""
},
"require": {
"ext-amqp": "*",
"php": ">=8.0.2",
"symfony/messenger": "^5.4|^6.0"
},
"require-dev": {
"symfony/event-dispatcher": "^5.4|^6.0",
"symfony/process": "^5.4|^6.0",
"symfony/property-access": "^5.4|^6.0",
"symfony/serializer": "^5.4|^6.0"
},
"type": "symfony-messenger-bridge",
"autoload": {
"psr-4": {
"Symfony\\Component\\Messenger\\Bridge\\Amqp\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony AMQP extension Messenger Bridge",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/amqp-messenger/tree/v6.0.5"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2022-02-09T15:52:48+00:00"
},
{
"name": "symfony/apache-pack",
"version": "v1.0.1",

View File

@@ -21,8 +21,33 @@ services:
MYSQL_DATABASE: db
app:
build: .docker/php
init: true
env_file: .env.docker.dist
ports:
- "8000:80"
volumes:
- ./:/var/www/html
async-commands-consumer:
build: .docker/php-cli
init: true
env_file: .env.docker.dist
working_dir: /var/www/html
command: "php bin/console messenger:consume commands_async -vv"
volumes:
- ./:/var/www/html
async-events-consumer:
build: .docker/php-cli
init: true
env_file: .env.docker.dist
working_dir: /var/www/html
command: "php bin/console messenger:consume events_async -vv"
volumes:
- ./:/var/www/html
async-projections-consumer:
build: .docker/php-cli
init: true
env_file: .env.docker.dist
working_dir: /var/www/html
command: "php bin/console messenger:consume projections_async -vv"
volumes:
- ./:/var/www/html

View File

@@ -331,6 +331,9 @@
"config/packages/snc_redis.yaml"
]
},
"symfony/amqp-messenger": {
"version": "v6.0.5"
},
"symfony/apache-pack": {
"version": "1.0",
"recipe": {