Skip to content

Commit 4544b37

Browse files
committed
WIP run test in dockerfile
1 parent ad5819e commit 4544b37

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

.dockerignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
!/lib/
3+
!/src/
4+
!/tests/
5+
!/benchmarks/
6+
!/composer.json
7+
!/phpunit.xml.*
8+
!/phpstan.neon.*
9+
!/.php_cs.*
10+
!/phpbench.json

CONTRIBUTING.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ You can run the tests by calling:
1818
composer test
1919
```
2020

21+
Or with docker:
22+
23+
```bash
24+
docker build . -t graphql-test && docker image prune -f >/dev/null && docker run --rm graphql-test test
25+
```
26+
2127
Code quality
2228
---------------------------
2329

@@ -27,6 +33,12 @@ Checking code standard, benchmark, and more.
2733
composer code-quality
2834
```
2935

36+
Or with docker:
37+
38+
```bash
39+
docker build . -t graphql-test && docker image prune -f >/dev/null && docker run --rm graphql-test code-quality
40+
```
41+
3042
Coding Standard
3143
----------------
3244

Dockerfile

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
FROM scratch AS composer_install_requirements
2+
3+
COPY composer.json /
4+
5+
FROM scratch AS test_source
6+
7+
COPY benchmarks/ benchmarks/
8+
COPY lib/ /lib/
9+
COPY src/ /src/
10+
COPY tests/ /tests/
11+
COPY phpunit.xml.* phpstan.neon.* .php_cs.* phpbench.json /
12+
13+
FROM alpine:3.9
14+
15+
# alpine php package does not include default extensions, be explicit
16+
RUN set -eu; \
17+
apk add --no-cache \
18+
php7 \
19+
php7-iconv \
20+
php7-json \
21+
php7-mbstring \
22+
php7-openssl \
23+
php7-phar \
24+
php7-tokenizer \
25+
php7-xml \
26+
php7-xmlwriter \
27+
php7-dom \
28+
;
29+
30+
RUN set -eu; \
31+
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"; \
32+
EXPECTED_SIGNATURE="$(wget -q -O - https://composer.github.io/installer.sig)"; \
33+
ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"; \
34+
\
35+
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]; then \
36+
>&2 echo 'ERROR: Invalid installer signature'; \
37+
rm composer-setup.php; \
38+
exit 1; \
39+
fi; \
40+
\
41+
php composer-setup.php --install-dir=/usr/local/bin --filename=composer; \
42+
rm composer-setup.php
43+
44+
WORKDIR /opt/test
45+
46+
COPY --from=composer_install_requirements / .
47+
48+
RUN composer install
49+
50+
COPY --from=test_source / .
51+
52+
RUN echo "memory_limit=1G" > /etc/php7/conf.d/99-custom.ini
53+
54+
ENTRYPOINT ["composer"]

0 commit comments

Comments
 (0)