Permalink
Browse files

Step 6. Consuming the messages in PHP

  • Loading branch information...
nielsvandermolen committed Oct 30, 2018
1 parent b41bf9d commit 480cb2caf1ec2172d9d57c9f9f26cabfdadd2355
@@ -1,3 +1,3 @@
FROM nginx:latest
COPY ./build/nginx/default.conf /etc/nginx/conf.d/
COPY . /var/www/project
COPY project/ /var/www/project
@@ -11,5 +11,5 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& docker-php-ext-enable amqp # Enable the Extension
RUN curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer
COPY . /var/www/project
COPY project/ /var/www/project
WORKDIR /var/www/project/
@@ -0,0 +1,17 @@
FROM php:fpm
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
zlib1g-dev \
libxml2-dev \
librabbitmq-dev \
&& docker-php-ext-install \
pdo_mysql \
zip \
&& pecl install amqp \
&& docker-php-ext-enable amqp # Enable the Extension
RUN curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer
COPY project/ /var/www/project
COPY build/php-consume/ /var/www/scripts/
WORKDIR /var/www/project/
ENTRYPOINT ["bash", "/var/www/scripts/message_script.sh"]
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
sleep 10;
/var/www/project/bin/console messenger:consume-messages >&1;
@@ -13,6 +13,18 @@ services:
networks:
- symfony # Docker containers (services) that need to connect to each other should be on the same network.
php-consume:
build:
context: .
dockerfile: Dockerfile-php-consume
environment:
- DATABASE_URL=mysql://root:root@db:3306/project_db
- MESSENGER_TRANSPORT_DSN=amqp://guest:guest@rabbitmq:5672/%2f/messages
volumes:
- ./project/:/var/www/project/
networks:
- symfony
nginx:
build:
context: .
@@ -16,6 +16,6 @@ public function __invoke(SleepMessage $sleepMessage)
# Simulate a long running process.
sleep($seconds);
echo $output;
echo $output . PHP_EOL;
}
}

0 comments on commit 480cb2c

Please sign in to comment.