Skip to content

Commit 57010c0

Browse files
authoredFeb 19, 2023
Merge pull request #2514 from jenssegers/improve-docker
chore: improve docker tests
2 parents 7dab675 + c380ce3 commit 57010c0

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed
 

‎Dockerfile

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
ARG PHP_VERSION=8.0
2-
ARG COMPOSER_VERSION=2.0
1+
ARG PHP_VERSION=8.1
2+
ARG COMPOSER_VERSION=2.5.4
33

4-
FROM composer:${COMPOSER_VERSION}
54
FROM php:${PHP_VERSION}-cli
65

76
RUN apt-get update && \
@@ -10,6 +9,16 @@ RUN apt-get update && \
109
pecl install xdebug && docker-php-ext-enable xdebug && \
1110
docker-php-ext-install -j$(nproc) pdo_mysql zip
1211

13-
COPY --from=composer /usr/bin/composer /usr/local/bin/composer
12+
COPY --from=composer:${COMPOSER_VERSION} /usr/bin/composer /usr/local/bin/composer
1413

1514
WORKDIR /code
15+
16+
COPY composer.* ./
17+
18+
RUN composer install
19+
20+
COPY ./ ./
21+
22+
RUN composer install
23+
24+
CMD ["./vendor/bin/phpunit"]

‎docker-compose.yml

+5-8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ version: '3'
33
services:
44
tests:
55
container_name: tests
6+
tty: true
67
build:
78
context: .
89
dockerfile: Dockerfile
@@ -15,20 +16,16 @@ services:
1516

1617
mysql:
1718
container_name: mysql
18-
image: mysql:5.7
19+
image: mysql:8.0
1920
ports:
20-
- 3306:3306
21+
- "3306:3306"
2122
environment:
2223
MYSQL_ROOT_PASSWORD:
2324
MYSQL_DATABASE: unittest
2425
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
25-
logging:
26-
driver: none
2726

2827
mongodb:
2928
container_name: mongodb
30-
image: mongo
29+
image: mongo:latest
3130
ports:
32-
- 27017:27017
33-
logging:
34-
driver: none
31+
- "27017:27017"

‎phpunit.xml.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
</testsuite>
3939
</testsuites>
4040
<php>
41-
<env name="MONGODB_URI" value="mongodb://127.0.0.1/" />
41+
<env name="MONGODB_URI" value="mongodb://mongodb/" />
4242
<env name="MONGODB_DATABASE" value="unittest"/>
4343
<env name="MYSQL_HOST" value="mysql"/>
4444
<env name="MYSQL_PORT" value="3306"/>

0 commit comments

Comments
 (0)
Please sign in to comment.