Merge pull request #51 from dunglas/upgrade-docker

Upgrade Dockerfile
This commit is contained in:
Maxime Helias
2019-12-20 18:13:44 +01:00
committed by GitHub
9 changed files with 183 additions and 110 deletions

View File

@@ -37,9 +37,9 @@ it's recommended to add a custom stage to the end of the `Dockerfile`.
```Dockerfile
# Dockerfile
FROM symfony_docker_php as symfony_docker_php_dev
FROM symfony_php as symfony_php_dev
ARG XDEBUG_VERSION=2.6.0
ARG XDEBUG_VERSION=2.8.0
RUN set -eux; \
apk add --no-cache --virtual .build-deps $PHPIZE_DEPS; \
pecl install xdebug-$XDEBUG_VERSION; \
@@ -55,13 +55,13 @@ configuration remains untouched.
As example, an override could look like this:
```yaml
version: '3.4'
version: "3.4"
services:
app:
php:
build:
context: .
target: symfony_docker_php_dev
target: symfony_php_dev
environment:
# See https://docs.docker.com/docker-for-mac/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host
# See https://github.com/docker/for-linux/issues/264
@@ -73,34 +73,31 @@ services:
idekey=PHPSTORM
# This should correspond to the server declared in PHPStorm `Preferences | Languages & Frameworks | PHP | Servers`
# Then PHPStorm will use the corresponding path mappings
PHP_IDE_CONFIG: serverName=symfony-docker
PHP_IDE_CONFIG: serverName=symfony
```
Then run:
````bash
```bash
docker-compose up -d
````
```
If `docker-compose.yaml` and a `docker-compose.override.yaml` are present on the same directory level, Docker Compose combines the two files into a single configuration, applying the configuration in the `docker-compose.override.yaml` file over and in addition to the values in the `docker-compose.yaml` file.
If `docker-compose.yml` and a `docker-compose.override.yml` are present on the same directory level, Docker Compose combines the two files into a single configuration, applying the configuration in the `docker-compose.override.yml` file over and in addition to the values in the `docker-compose.yml` file.
### Troubleshooting
Inspect the installation with the following command. The requested Xdebug version should be displayed in the output.
```bash
$ docker-compose exec app php --version
$ docker-compose exec php php --version
PHP 7.2.8 (cli) (built: Jul 21 2018 08:09:37) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.8, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
PHP ...
with Xdebug v2.8.0 ...
```
### Editing Permissions on Linux
If you work on linux and cannot edit some of the project files right after the first installation, you can run `docker-compose run --rm app chown -R $(id -u):$(id -g) .` to set yourself as owner of the project files that were created by the docker container.
If you work on linux and cannot edit some of the project files right after the first installation, you can run `docker-compose run --rm php chown -R $(id -u):$(id -g) .` to set yourself as owner of the project files that were created by the docker container.
## Credits