Skip to content

Commit 6f5fc74

Browse files
bors[bot]meili-botbrunoocasali
authored
Merge #182
182: Improve Docker configuration in the package r=brunoocasali a=meili-bot _This PR is auto-generated._ Add a basic Docker configuration based on this [integration-guides issue](meilisearch/integration-guides#199). Co-authored-by: meili-bot <[email protected]> Co-authored-by: Bruno Casali <[email protected]>
2 parents 74dfa0c + 7ab3e9d commit 6f5fc74

File tree

9 files changed

+114
-101
lines changed

9 files changed

+114
-101
lines changed

.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ indent_style = space
1111
indent_size = 4
1212
max_line_length = 120
1313

14+
[*.{yml,json}]
15+
indent_size = 2

.github/workflows/tests.yml

Lines changed: 55 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -10,63 +10,64 @@ on:
1010
- main
1111

1212
jobs:
13-
integration-tests:
14-
# Will not run if the event is a PR to bump-meilisearch-v* (so a pre-release PR)
15-
# Will still run for each push to bump-meilisearch-v*
16-
if: github.event_name != 'pull_request' || !startsWith(github.base_ref, 'bump-meilisearch-v')
17-
runs-on: ubuntu-latest
18-
strategy:
19-
matrix:
20-
php-version: ['7.4', '8.0', '8.1']
21-
include:
22-
- php-version: '7.4'
23-
sf-version: '4.4.*'
24-
- php-version: '7.4'
25-
sf-version: '5.4.*'
26-
- php-version: '8.0'
27-
sf-version: '6.0.*'
28-
- php-version: '8.1'
29-
sf-version: '6.0.*'
30-
- php-version: '8.1'
31-
sf-version: '6.1.*'
32-
name: integration-tests (PHP ${{ matrix.php-version }})
33-
steps:
34-
- uses: actions/checkout@v3
35-
- name: Install PHP
36-
uses: shivammathur/setup-php@v2
37-
with:
38-
php-version: ${{ matrix.php-version }}
39-
tools: composer:v2, flex
40-
- name: Validate composer.json and composer.lock
41-
run: composer validate
42-
- name: Install dependencies
43-
env:
44-
SYMFONY_REQUIRE: ${{ matrix.sf-version }}
45-
run: composer install --prefer-dist --no-progress --quiet
46-
- name: Meilisearch setup with Docker
47-
run: docker run -d -p 7700:7700 getmeili/meilisearch:latest meilisearch --master-key=masterKey --no-analytics
48-
- name: Run test suite
49-
run: composer test:unit
13+
integration-tests:
14+
# Will not run if the event is a PR to bump-meilisearch-v* (so a pre-release PR)
15+
# Will still run for each push to bump-meilisearch-v*
16+
if: github.event_name != 'pull_request' || !startsWith(github.base_ref, 'bump-meilisearch-v')
17+
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
php-version: ['7.4', '8.0', '8.1']
21+
include:
22+
- php-version: '7.4'
23+
sf-version: '4.4.*'
24+
- php-version: '7.4'
25+
sf-version: '5.4.*'
26+
- php-version: '8.0'
27+
sf-version: '6.0.*'
28+
- php-version: '8.1'
29+
sf-version: '6.0.*'
30+
- php-version: '8.1'
31+
sf-version: '6.1.*'
5032

51-
code-style:
52-
runs-on: ubuntu-latest
53-
name: 'Code style'
54-
steps:
55-
- uses: actions/checkout@v3
33+
name: integration-tests (PHP ${{ matrix.php-version }})
34+
steps:
35+
- uses: actions/checkout@v3
36+
- name: Install PHP
37+
uses: shivammathur/setup-php@v2
38+
with:
39+
php-version: ${{ matrix.php-version }}
40+
tools: composer:v2, flex
41+
- name: Validate composer.json and composer.lock
42+
run: composer validate
43+
- name: Install dependencies
44+
env:
45+
SYMFONY_REQUIRE: ${{ matrix.sf-version }}
46+
run: composer install --prefer-dist --no-progress --quiet
47+
- name: Meilisearch setup with Docker
48+
run: docker run -d -p 7700:7700 getmeili/meilisearch:latest meilisearch --master-key=masterKey --no-analytics
49+
- name: Run test suite
50+
run: composer test:unit
5651

57-
- name: Install PHP
58-
uses: shivammathur/setup-php@v2
59-
with:
60-
php-version: '8.0'
52+
code-style:
53+
runs-on: ubuntu-latest
54+
name: 'Code style'
55+
steps:
56+
- uses: actions/checkout@v3
6157

62-
- name: Validate composer.json and composer.lock
63-
run: composer validate
58+
- name: Install PHP
59+
uses: shivammathur/setup-php@v2
60+
with:
61+
php-version: '8.0'
6462

65-
- name: Install dependencies
66-
run: composer install --prefer-dist --no-progress --quiet
63+
- name: Validate composer.json and composer.lock
64+
run: composer validate
6765

68-
- name: PHP CS Fixer
69-
run: composer lint:check
66+
- name: Install dependencies
67+
run: composer install --prefer-dist --no-progress --quiet
7068

71-
- name: PHPstan
72-
run: composer phpstan
69+
- name: PHP CS Fixer
70+
run: composer lint:check
71+
72+
- name: PHPstan
73+
run: composer phpstan

CONTRIBUTING.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,14 @@ First of all, thank you for contributing to Meilisearch! The goal of this docume
3434

3535
#### Setup
3636

37-
Install the dependencies:
37+
You can set up your local environment natively or using `docker`, check out the [`docker-compose.yml`](/docker-compose.yml).
38+
39+
Example of running all the checks with docker:
40+
```bash
41+
docker-compose run --rm package bash -c "composer install && composer test:unit && composer lint:check"
42+
```
43+
44+
To install dependencies:
3845

3946
```sh
4047
composer install
@@ -62,6 +69,15 @@ These commands do not work on MacOS, see [this issue](https://github.com/meilise
6269

6370
#### Setup
6471

72+
You can set up your local environment natively or using `docker`, check out the [`docker-compose.yml`](/docker-compose.yml).
73+
74+
Example of running all the checks with docker:
75+
```bash
76+
docker-compose run --rm package bash -c "list of the commands required to build + run tests + run linters"
77+
```
78+
79+
To install dependencies:
80+
6581
To start and build your Docker environment, just execute the next command in a terminal:
6682

6783
```sh
@@ -76,7 +92,7 @@ Each Pull Request should pass the tests, and the linter to be accepted.
7692

7793
```sh
7894
# Tests
79-
docker-compose exec -e MEILISEARCH_URL=http://meilisearch:7700 php composer test:unit
95+
docker-compose exec -e MEILISEARCH_HOST=http://meilisearch:7700 php composer test:unit
8096
# Linter
8197
docker-compose exec php composer lint:check
8298
# Linter (with auto-fix)

Dockerfile

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,17 @@
1-
FROM php:8.0-fpm-alpine as php
2-
3-
# persistent / runtime deps
4-
RUN apk add --no-cache \
5-
acl \
6-
fcgi \
7-
file \
8-
gettext \
9-
git \
10-
;
1+
FROM php:8.0-fpm as php
112

123
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
134
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
145
ENV COMPOSER_ALLOW_SUPERUSER=1
156

16-
WORKDIR /usr/src
17-
18-
# prevent the reinstallation of vendors at every changes in the source code
19-
COPY composer.json ./
20-
RUN set -eux; \
21-
composer install; \
22-
composer clear-cache
23-
24-
# copy only specifically what we need
25-
COPY src src/
26-
COPY tests tests/
7+
RUN apt-get update && apt-get install -y \
8+
libfcgi0ldbl \
9+
zlib1g-dev \
10+
gettext \
11+
libzip-dev \
12+
unzip \
13+
git
2714

28-
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint
29-
RUN chmod +x /usr/local/bin/docker-entrypoint
15+
RUN docker-php-ext-install zip
3016

31-
ENTRYPOINT ["docker-entrypoint"]
3217
CMD ["php-fpm"]

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@
5454
}
5555
},
5656
"config": {
57-
"sort-packages": true
57+
"sort-packages": true,
58+
"allow-plugins": {
59+
"phpstan/extension-installer": true
60+
}
5861
},
5962
"scripts": {
6063
"phpstan": "./vendor/bin/phpstan --memory-limit=1G --ansi",

docker-compose.yaml

Lines changed: 0 additions & 18 deletions
This file was deleted.

docker-compose.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: '3.8'
2+
3+
services:
4+
package:
5+
build: .
6+
tty: true
7+
stdin_open: true
8+
working_dir: /home/package
9+
environment:
10+
- MEILISEARCH_HOST=http://meilisearch:7700
11+
depends_on:
12+
- meilisearch
13+
links:
14+
- meilisearch
15+
volumes:
16+
- ./:/home/package:rw,cached
17+
18+
meilisearch:
19+
image: getmeili/meilisearch:latest
20+
ports:
21+
- "7700"
22+
environment:
23+
- MEILI_MASTER_KEY=masterKey
24+
- MEILI_NO_ANALYTICS=true

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<env name="APP_ENV" value="test"/>
1313
<env name="APP_DEBUG" value="false"/>
1414
<env name="MEILISEARCH_PREFIX" value="sf_phpunit_"/>
15-
<env name="MEILISEARCH_URL" value="http://127.0.0.1:7700"/>
15+
<env name="MEILISEARCH_HOST" value="http://127.0.0.1:7700"/>
1616
<env name="MEILISEARCH_API_KEY" value="masterKey"/>
1717
<env name="TRAVIS_JOB_NUMBER" value=""/>
1818
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/>

tests/config/meili_search.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
meili_search:
2-
url: '%env(MEILISEARCH_URL)%'
2+
url: '%env(MEILISEARCH_HOST)%'
33
api_key: '%env(MEILISEARCH_API_KEY)%'
44
prefix: '%env(MEILISEARCH_PREFIX)%_'
55
nbResults: 12

0 commit comments

Comments
 (0)