Skip to content

Commit

Permalink
fix docker setup
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasmure committed Jun 11, 2019
1 parent 7a92aba commit f2f3822
Show file tree
Hide file tree
Showing 12 changed files with 212 additions and 122 deletions.
15 changes: 2 additions & 13 deletions .dockerignore
@@ -1,13 +1,2 @@
.idea/
bin/tests-all
doc/
vendor/
.dockerignore
.editorconfig
.gitignore
.travis.yml
appveyor.yml
composer.lock
docker-compose.yml
LICENSE
README.md
# ignore all by default
*
56 changes: 0 additions & 56 deletions Dockerfile-php71

This file was deleted.

21 changes: 21 additions & 0 deletions Makefile
@@ -0,0 +1,21 @@
PHP_VERSION ?= 7.2

.PHONY: dev
dev:
cp .env.dist .env

.PHONY: build
build:
docker-compose build php${PHP_VERSION}

.PHONY: install-deps
install-deps:
docker/run-task php${PHP_VERSION} composer install

.PHONY: tests
tests:
docker/run-task php${PHP_VERSION} bin/tests

.PHONY: clear-deps
clear-deps:
rm -rf vendor/ composer.lock
56 changes: 41 additions & 15 deletions README.md
Expand Up @@ -32,8 +32,8 @@ Read the official [Gaufrette documentation](http://knplabs.github.io/Gaufrette/)

### Metapackages for adapters

Every maintained adapter now have a dedicated metapackage. You can [find the list on packagist](https://packagist.org/packages/gaufrette/).
**We highly recommend you to use them as they contain their own requirements**: you don't need to worry about third-party dependencies
Every maintained adapter now have a dedicated metapackage. You can [find the list on packagist](https://packagist.org/packages/gaufrette/).
**We highly recommend you to use them as they contain their own requirements**: you don't need to worry about third-party dependencies
to install before using Gaufrette anymore.

### Symfony integration
Expand All @@ -42,7 +42,7 @@ Symfony integration is available through [KnpLabs/KnpGaufretteBundle](https://gi

### Maintainers

Here is the list of dedicated maintainer(s) for every adapter not deprecated. If you don't receive any response to
Here is the list of dedicated maintainer(s) for every adapter not deprecated. If you don't receive any response to
your issue or pull request in a timely manner, ping us:

| Adapter | Referent |
Expand All @@ -62,21 +62,47 @@ your issue or pull request in a timely manner, ping us:

For `InMemory`, `Local` and `Zip` adapters everyone in this list is considered as a maintainer.

### Launch the Test Suite
### Development

Requires:
* docker
Requires the latest versions of :
* docker-ce
* docker-compose

Build images:

$ docker-compose build

Launch the tests:

$ bin/tests-all

Is it green?
1) Create `.env` file :
```bash
$ make dev
```
and configure it as you want.

2) Build the php docker image :
```bash
$ make build
```

3) Install dependencies :
```bash
$ make install-deps
```

4) Run tests :
```bash
$ make tests
```

You can also use a different php version, simply set the `PHP_VERSION` env var
to any of these values when calling a make target :
- `7.1`
- `7.2` (default)
- `7.3` (the docker setup for php 7.3 is available, however the image fails
to build for now as the [ssh2 extension is not available for php 7/3 yet](https://serverpilot.io/docs/how-to-install-the-php-ssh2-extension))
See the [`docker-compose.yml`](/docker-compose.yml) file for more details.

You'll need to clear the previously installed dependencies when switching from
a version to an other, to do so, run :
```bash
$ make clear-deps
$ PHP_VERSION=<the_version_you_want_to_use> make build install-deps
```

### Note

Expand Down
1 change: 0 additions & 1 deletion bin/tests
@@ -1,7 +1,6 @@
#!/bin/sh

set -o nounset
set -o errexit
set -o xtrace

DIR=$(dirname $0)/..
Expand Down
7 changes: 0 additions & 7 deletions bin/tests-all

This file was deleted.

44 changes: 35 additions & 9 deletions docker-compose.yml
@@ -1,16 +1,43 @@
version: '3'
version: '3.4'

services:
php71:
php7.1:
build:
context: .
dockerfile: ./Dockerfile-php71
dockerfile: docker/php/Dockerfile
target: php7.1
env_file: .env
volumes:
- './:/app'
- './docker/php/php.ini:/usr/local/etc/php/php.ini:ro'
depends_on:
- mongodb
- sftp
- ftp

php7.2:
build:
context: .
dockerfile: docker/php/Dockerfile
target: php7.2
env_file: .env
volumes:
- './spec:/usr/src/gaufrette/spec:rw'
- './src:/usr/src/gaufrette/src:ro'
- './tests:/usr/src/gaufrette/tests:rw'
- './bin/tests:/usr/src/gaufrette/bin/tests:ro'
- './:/app'
- './docker/php/php.ini:/usr/local/etc/php/php.ini:ro'
depends_on:
- mongodb
- sftp
- ftp

php7.3:
build:
context: .
dockerfile: docker/php/Dockerfile
target: php7.3
env_file: .env
volumes:
- './:/app'
- './docker/php/php.ini:/usr/local/etc/php/php.ini:ro'
depends_on:
- mongodb
- sftp
Expand All @@ -25,7 +52,6 @@ services:

ftp:
build:
context: docker
dockerfile: Dockerfile-ftp
context: ./docker/ftp
environment:
PUBLICHOST: 'ftp'
File renamed without changes.
21 changes: 0 additions & 21 deletions docker/install-composer.sh

This file was deleted.

98 changes: 98 additions & 0 deletions docker/php/Dockerfile
@@ -0,0 +1,98 @@
# To copy composer binary file
FROM composer:1.8.5 as composer

################################################################################

FROM php:7.1-alpine as php7.1

RUN apk add --no-cache \
autoconf \
g++\
git \
libssh2-dev \
make \
zlib-dev \
&& pecl install \
mongodb \
ssh2-1.1.2

RUN docker-php-ext-install \
zip \
&& docker-php-ext-enable \
mongodb \
ssh2

COPY --from=composer /usr/bin/composer /usr/bin/composer
ENV COMPOSER_HOME /var/cache/composer
RUN mkdir /var/cache/composer \
&& chown 1000:1000 /var/cache/composer

USER 1000

RUN composer global require "hirak/prestissimo" --prefer-dist

WORKDIR /app

################################################################################

FROM php:7.2-alpine as php7.2

RUN apk add --no-cache \
autoconf \
g++\
git \
libssh2-dev \
make \
zlib-dev \
&& pecl install \
mongodb \
ssh2-1.1.2

RUN docker-php-ext-install \
zip \
&& docker-php-ext-enable \
mongodb \
ssh2

COPY --from=composer /usr/bin/composer /usr/bin/composer
ENV COMPOSER_HOME /var/cache/composer
RUN mkdir /var/cache/composer \
&& chown 1000:1000 /var/cache/composer

USER 1000

RUN composer global require "hirak/prestissimo" --prefer-dist

WORKDIR /app

################################################################################

FROM php:7.3-alpine as php7.3

RUN apk add --no-cache \
autoconf \
g++\
git \
libssh2-dev \
make \
zlib-dev \
&& pecl install \
mongodb \
ssh2-1.1.2

RUN docker-php-ext-install \
zip \
&& docker-php-ext-enable \
mongodb \
ssh2

COPY --from=composer /usr/bin/composer /usr/bin/composer
ENV COMPOSER_HOME /var/cache/composer
RUN mkdir /var/cache/composer \
&& chown 1000:1000 /var/cache/composer

USER 1000

RUN composer global require "hirak/prestissimo" --prefer-dist

WORKDIR /app
File renamed without changes.
15 changes: 15 additions & 0 deletions docker/run-task
@@ -0,0 +1,15 @@
#!/bin/bash
# Usage: run-task SERVICE [CMD...]

set -o nounset

# env var used by the `docker-compose` command
COMPOSE_FILE="$(dirname $0)/docker-compose.yml"

docker-compose run --rm "${@}"
EXIT_CODE="${?}"

# stop the other services linked to the task
docker-compose down

exit "${EXIT_CODE}"

0 comments on commit f2f3822

Please sign in to comment.