Skip to content

Instantly share code, notes, and snippets.

@hemilioaraujo
Last active April 11, 2023 09:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hemilioaraujo/f94d32b6198fc1826c9c54c4c508f884 to your computer and use it in GitHub Desktop.
Save hemilioaraujo/f94d32b6198fc1826c9c54c4c508f884 to your computer and use it in GitHub Desktop.
Ambiente PHP -> Docker + PHP + MySql + VSCode
version: "3.7"
# Networks
networks:
# Internal network
internal:
driver: bridge
# Volumes
volumes:
# MySQL volume
app-mysql_data:
driver: local
# Services
services:
# MySQL
app-mysql:
image: mysql:5.7
container_name: ${APP_NAME}_db
networks:
- internal
volumes:
# Os volumes ficam no diretório /var/lib/docker/volumes/
- app-mysql_data:/var/lib/mysql
- .:/var/www/app
working_dir: /var/www/app
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=${DB_DATABASE}
- MYSQL_USER=${DB_USERNAME}
- MYSQL_PASSWORD=${DB_PASSWORD}
ports:
- "3306:3306"
# Nginx
app-nginx:
image: webdevops/php-nginx-dev:8.0
container_name: ${APP_NAME}_web
networks:
- internal
depends_on:
- app-mysql
volumes:
- .:/var/www/app
working_dir: /var/www/app
environment:
- WEB_DOCUMENT_ROOT=/var/www/app/public
- PHP_DATE_TIMEZONE=UTC
- PHP_DISPLAY_ERRORS=0
- WEB_DOCUMENT_INDEX=index.php
- PHP_MEMORY_LIMIT=4096M
- PHP_MAX_EXECUTION_TIME=86400
- PHP_POST_MAX_SIZE=500M
- PHP_UPLOAD_MAX_FILESIZE=500M
- PHP_DEBUGGER="xdebug"
# - PHP_IDE_CONFIG="serverName=_"
# xdebug v3
- XDEBUG_MODE=debug
- XDEBUG_START_WITH_REQUEST=yes
- XDEBUG_CLIENT_HOST=host.docker.internal
- XDEBUG_CLIENT_PORT=9090
- XDEBUG_OUTPUT_DIR=/var/www/app/.xdebug
expose:
- 9090
ports:
- "8080:80"
# Obrigado @wilcorrea
// Arquivo de configuração do vs code para utilizar o debug com xdebug
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9090,
"log": true,
"stopOnEntry": false,
"pathMappings": {
// DEVE APONTAR QUEM SÃO OS ARQUIVOS NO CONTAINER E NO HOST
// DIRETÓRIO DO CONTAINER : DIRETÓRIO DO HOST
"/var/www/app/": "${workspaceFolder}"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment