Skip to content

Add debugging section to the core manual #560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 1, 2018
Merged

Conversation

hschaeidt
Copy link
Contributor

resolves #551

# the different stages of this Dockerfile are meant to be built into separate images
# https://docs.docker.com/compose/compose-file/#target

+ARG BUILD_ENV=prod
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used in line 43, to distinguish between the prod and dev image. The alternative would be to override the build target for the php service.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to add a stage before doing all the composer stuff and before the entrypoints are set. Otherwise it would probably also require to re-set the entrypoints as they are set in api_platform_php, for the dev stage too. And that leads to duplicate code. But I'm usually not a docker user, so please correct me if I'm wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alternative would be to override the build target for the php service.

Yes, that is what should be done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dev stage cannot be here. It'll get in the way of other stages. 😄

It has to be at the end, as I've mentioned in #560 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You only need to re-set the ENTRYPOINT if you're setting CMD. If you don't change that, it'll simply use what's already set in the base image.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. It makes sense said like that and keeps things simpler

ARG VARNISH_VERSION=6.0

-FROM php:${PHP_VERSION}-fpm-alpine AS api_platform_php
+FROM php:${PHP_VERSION}-fpm-alpine AS api_platform_php_prod
Copy link
Contributor

@teohhanhui teohhanhui Aug 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep this stage untouched, but instead put the api_platform_php_dev stage at the very end of the Dockerfile (after Varnish).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, with this change we don't have to use diff format, but just say to append to the end of the Dockerfile.

@@ -0,0 +1,83 @@
# Debugging

The default docker stack is shipped without a xdebug/dev stage. It is easy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker => Docker
xdebug => Xdebug.
Remove /dev?
It is => It's
develoment => development
api => API


## Add a development stage to the Dockerfile

To avoid deploying api-platform to production with an active xdebug extension,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api-platform => API Platform
xdebug => Xdebug
is is => it's

@hschaeidt hschaeidt force-pushed the 2.3 branch 2 times, most recently from 8ebc0b7 to 8edd55a Compare August 8, 2018 11:12

The default Docker stack is shipped without a Xdebug stage. It's easy
though to add [Xdebug](https://xdebug.org/) to your project, for development
purposes such as debugging tests or api requests remotely.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api -> API

ARG XDEBUG_VERSION=2.6.0
RUN apk add --no-cache $PHPIZE_DEPS; \
pecl install xdebug-$XDEBUG_VERSION; \
docker-php-ext-enable xdebug
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ARG XDEBUG_VERSION=2.6.0
RUN set -eux; \
	apk add --no-cache --virtual .build-deps $PHPIZE_DEPS; \
	pecl install xdebug-$XDEBUG_VERSION; \
	docker-php-ext-enable xdebug; \
	apk del .build-deps


## Configure Xdebug with docker-compose override

Using a [override](https://docs.docker.com/compose/reference/overview/#specifying-multiple-compose-files)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a -> an

docker-php-ext-enable xdebug
```

## Configure Xdebug with docker-compose override
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Configure Xdebug with Docker Compose Override

(since we use title case)

though to add [Xdebug](https://xdebug.org/) to your project, for development
purposes such as debugging tests or api requests remotely.

## Add a development stage to the Dockerfile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a Development Stage to the Dockerfile

(since we use title case)

#
# Choose some other port than `9000`, as this one is already occupied by FPM
# Make sure to also change your listening port in the IDE to this value
XDEBUG_CONFIG: remote_enable=1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

      XDEBUG_CONFIG: >-
        remote_enable=1
        ...

(folded scalar, with "strip" block chomping)


```yml
version: '3.4'
services:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong indentation (remove leading space)


## Troubleshooting

Inspect the installation with the following command, the requested Xdebug
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inspect the installation with the following command. The requested Xdebug version should be displayed in the output.

@hschaeidt
Copy link
Contributor Author

Thanks for this in-depth review. I will fix the rest soon.

@dunglas dunglas merged commit 1af09b9 into api-platform:2.3 Oct 1, 2018
@dunglas
Copy link
Member

dunglas commented Oct 1, 2018

Thanks @hschaeidt. Very useful PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants