Skip to content

Commit bdb29d2

Browse files
committed
Add make targets to start up docker test env, and a target to run tests via docker
1 parent 99eeb3a commit bdb29d2

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
DOCKER_FRESH ?= false
2+
13
.PHONY: test
24
test:
35
./vendor/bin/phpunit
@@ -18,3 +20,21 @@ benchmark:
1820
php benchmark/stream_tmp_produce.php 1000
1921
@echo "Socket produce 1k:"
2022
php benchmark/socket_tmp_produce.php 1000
23+
24+
.PHONY: docker-test-env
25+
docker-test-env:
26+
ifeq ($(DOCKER_FRESH),true)
27+
docker build --pull --no-cache --tag=php-amqplib-php:latest $(CURDIR)/docker/php
28+
docker compose build --no-cache --pull
29+
docker compose up --pull always --detach
30+
else
31+
docker build --tag=php-amqplib-php:latest $(CURDIR)/docker/php
32+
docker compose up --detach
33+
endif
34+
35+
.PHONY: docker-test
36+
docker-test:
37+
docker run --env-file $(CURDIR)/test.env --network php-amqplib_default \
38+
--volume $(CURDIR):/src --workdir /src \
39+
--user "$$(id -u):$$(id -g)" php-amqplib-php:latest \
40+
/bin/sh -c '/usr/bin/composer install && ./vendor/bin/phpunit'

docker-compose.yaml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,6 @@ x-networks: &networks
44
- ip6net
55

66
services:
7-
php:
8-
build: ./docker/php
9-
volumes:
10-
- .:/src
11-
working_dir: /src
12-
environment:
13-
- TEST_RABBITMQ_HOST=php-amqplib-rabbitmq
14-
- TOXIPROXY_HOST=php-amqplib-toxiproxy
15-
- TOXIPROXY_AMQP_PORT=5673
16-
depends_on:
17-
- php-amqplib-rabbitmq
18-
- php-amqplib-toxiproxy
19-
entrypoint: ['tail', '-f', '/dev/null']
20-
<<: *networks
21-
227
php-amqplib-rabbitmq:
238
image:
249
rabbitmq:3-management

docker/php/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:8-cli
1+
FROM php:7.2-cli
22

33
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/download/2.2.16/install-php-extensions /usr/local/bin/
44
COPY --from=composer /usr/bin/composer /usr/bin/composer

test.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
TEST_RABBITMQ_HOST=php-amqplib-rabbitmq
2+
TOXIPROXY_HOST=php-amqplib-toxiproxy
3+
TOXIPROXY_AMQP_PORT=5673

0 commit comments

Comments
 (0)