Skip to content

Commit 8f7f938

Browse files
committed
[amqp-ext][docker] Incorporate amqp ext compilation to docker build process.
1 parent 1be9903 commit 8f7f938

File tree

7 files changed

+38
-13
lines changed

7 files changed

+38
-13
lines changed

bin/build-enqueue-dev-image.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
set -x
5+
6+
(cd docker && docker build --rm --force-rm --no-cache --pull --squash --tag "enqueue/dev:latest" -f Dockerfile .)
7+
(cd docker && docker login --username="$DOCKER_USER" --password="$DOCKER_PASSWORD")
8+
(cd docker && docker push "enqueue/dev:latest")

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"config": {
5858
"bin-dir": "bin",
5959
"platform": {
60-
"ext-amqp": "1.7",
60+
"ext-amqp": "1.9.3",
6161
"ext-gearman": "1.1",
6262
"ext-rdkafka": "3.3"
6363
}

docker-compose.yml

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ version: '2'
33
services:
44
dev:
55
image: enqueue/dev:latest
6-
# build: { context: docker, dockerfile: Dockerfile }
76
depends_on:
87
- rabbitmq
98
- mysql
@@ -48,7 +47,6 @@ services:
4847

4948
rabbitmq:
5049
image: 'enqueue/rabbitmq:latest'
51-
# build: { context: docker, dockerfile: Dockerfile.rabbitmq }
5250
environment:
5351
- RABBITMQ_DEFAULT_USER=guest
5452
- RABBITMQ_DEFAULT_PASS=guest

docker/Dockerfile

+20-7
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,34 @@ FROM formapro/nginx-php-fpm:latest-all-exts
33
## libs
44
RUN set -x && \
55
apt-get update && \
6-
apt-get install -y wget curl openssl ca-certificates nano netcat php-dev php-redis git python
6+
apt-get install -y --no-install-recommends --no-install-suggests wget curl openssl ca-certificates nano netcat php-dev php-redis git python
7+
8+
RUN set -x && \
9+
apt-get update && \
10+
apt-get install -y --no-install-recommends --no-install-suggests php-dev librabbitmq-dev make && \
11+
mkdir -p $HOME/php-amqp && \
12+
cd $HOME/php-amqp && \
13+
git clone https://github.com/pdezwart/php-amqp.git . && git checkout v1.9.3 && \
14+
phpize --clean && phpize && ./configure && make install
715

816
## confis
917

1018
# RUN rm -f /etc/php/7.0/cli/conf.d/*xdebug.ini
1119

1220
## librdkafka
13-
RUN git clone https://github.com/edenhill/librdkafka.git /root/librdkafka
14-
RUN cd /root/librdkafka && git checkout v0.11.0-RC2 && ./configure && make && make install
15-
RUN pecl install rdkafka
16-
RUN echo "extension=rdkafka.so" > /etc/php/7.1/cli/conf.d/10-rdkafka.ini
17-
RUN echo "extension=rdkafka.so" > /etc/php/7.1/fpm/conf.d/10-rdkafka.ini
21+
RUN set -x && \
22+
apt-get update && \
23+
apt-get install -y --no-install-recommends --no-install-suggests g++ php-pear php-dev && \
24+
mkdir -p $HOME/librdkafka && \
25+
cd $HOME/librdkafka && \
26+
git clone https://github.com/edenhill/librdkafka.git . && \
27+
git checkout v0.11.1 && \
28+
./configure && make && make install && \
29+
pecl install rdkafka && \
30+
echo "extension=rdkafka.so" > /etc/php/7.1/cli/conf.d/10-rdkafka.ini && \
31+
echo "extension=rdkafka.so" > /etc/php/7.1/fpm/conf.d/10-rdkafka.ini
1832

1933
COPY ./php/cli.ini /etc/php/7.1/cli/conf.d/1-dev_cli.ini
20-
COPY ./php/amqp.so /usr/lib/php/20160303/amqp.so
2134
COPY ./bin/dev_entrypoiny.sh /usr/local/bin/entrypoint.sh
2235
RUN chmod u+x /usr/local/bin/entrypoint.sh
2336

docker/php/amqp.so

-609 KB
Binary file not shown.

pkg/amqp-ext/AmqpConnectionFactory.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,17 @@ private function establishConnection()
125125

126126
$this->connection = new \AMQPConnection($extConfig);
127127

128-
$this->config->isPersisted() ? $this->connection->pconnect() : $this->connection->connect();
128+
$this->config->isPersisted() ?
129+
$this->connection->pconnect() :
130+
$this->connection->connect()
131+
;
129132
}
130133

131134
if (false == $this->connection->isConnected()) {
132-
$this->config->isPersisted() ? $this->connection->preconnect() : $this->connection->reconnect();
135+
$this->config->isPersisted() ?
136+
$this->connection->preconnect() :
137+
$this->connection->reconnect()
138+
;
133139
}
134140

135141
return $this->connection;

pkg/amqp-ext/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"license": "MIT",
88
"require": {
99
"php": ">=5.6",
10-
"ext-amqp": "^1.6",
10+
"ext-amqp": "^1.9.3",
1111

1212
"queue-interop/amqp-interop": "^0.7@dev",
1313
"enqueue/amqp-tools": "^0.8.4@dev"

0 commit comments

Comments
 (0)