Skip to content

Commit

Permalink
Devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
ili101 committed Mar 9, 2024
1 parent 4bf748a commit 959a835
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 7 deletions.
36 changes: 36 additions & 0 deletions .devcontainer/compose.devcontainer.yaml
@@ -0,0 +1,36 @@
version: '3.4'
services:
# Update this to the name of the service you want to work with in your docker-compose.yml file
php:
# Uncomment if you want to override the service's Dockerfile to one in the .devcontainer
# folder. Note that the path of the Dockerfile and context is relative to the *primary*
# docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile"
# array). The sample below assumes your primary file is in the root of your project.
#
# build:
# context: .
# dockerfile: .devcontainer/Dockerfile

volumes:
# Update this to wherever you want VS Code to mount the folder of your project
- .:/srv:cached

environment:
# See https://xdebug.org/docs/all_settings#mode
XDEBUG_MODE: debug
# Enable the step debugger
XDEBUG_SESSION: 1
# Override api/docker/php/conf.d/app.dev.ini
XDEBUG_CONFIG: "client_host=localhost"

# This Unset APP_ENV to allow Symfony to use the value from .env so you can set it on the fly.
# APP_ENV:

# Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust.
# cap_add:
# - SYS_PTRACE
# security_opt:
# - seccomp:unconfined

# Overrides default command so things don't shut down after the process ends.
# command: /bin/sh -c "while sleep 1000; do :; done"
48 changes: 48 additions & 0 deletions .devcontainer/devcontainer.json
@@ -0,0 +1,48 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
{
"name": "API Platform Devcontainer",

// Update the 'dockerComposeFile' list if you have more compose files or use different names.
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
"dockerComposeFile": [
"../compose.yaml",
"../compose.override.yaml",
"compose.devcontainer.yaml"
],

// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
"service": "php",

// The optional 'workspaceFolder' property is the path VS Code should open by default when
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
"workspaceFolder": "/srv",

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Uncomment the next line if you want start specific services in your Docker Compose config.
// "runServices": [],

// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
// "shutdownAction": "none",

// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": ". .devcontainer/install-dev-tools.sh",

// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"xdebug.php-debug"
]
}
}

// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
}
48 changes: 48 additions & 0 deletions .vscode/launch.json
@@ -0,0 +1,48 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 0,
"runtimeArgs": [
"-dxdebug.start_with_request=yes"
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
},
{
"name": "Launch Built-in web server",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-S",
"localhost:0"
],
"program": "",
"cwd": "${workspaceRoot}",
"port": 9003,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
}
]
}
4 changes: 2 additions & 2 deletions api/Dockerfile
Expand Up @@ -15,7 +15,7 @@ FROM dunglas/frankenphp:1-php8.3 AS frankenphp_upstream
# Base FrankenPHP image
FROM frankenphp_upstream AS frankenphp_base

WORKDIR /app
WORKDIR /srv/api

# persistent / runtime deps
# hadolint ignore=DL3008
Expand Down Expand Up @@ -58,7 +58,7 @@ CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile" ]
FROM frankenphp_base AS frankenphp_dev

ENV APP_ENV=dev XDEBUG_MODE=off
VOLUME /app/var/
VOLUME /srv/api/var/

RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"

Expand Down
2 changes: 1 addition & 1 deletion api/frankenphp/Caddyfile
Expand Up @@ -26,7 +26,7 @@
}
}

root * /app/public
root * /srv/api/public
encode {
zstd
br
Expand Down
2 changes: 1 addition & 1 deletion api/frankenphp/conf.d/app.prod.ini
@@ -1,2 +1,2 @@
opcache.preload_user = root
opcache.preload = /app/config/preload.php
opcache.preload = /srv/api/config/preload.php
6 changes: 3 additions & 3 deletions compose.override.yaml
Expand Up @@ -5,13 +5,13 @@ services:
context: ./api
target: frankenphp_dev
volumes:
- ./api:/app
- /app/var
- ./api:/srv/api
- /srv/api/var
- ./api/frankenphp/Caddyfile:/etc/caddy/Caddyfile:ro
- ./api/frankenphp/conf.d/app.dev.ini:/usr/local/etc/php/conf.d/app.dev.ini:ro
# If you develop on Mac or Windows you can remove the vendor/ directory
# from the bind-mount for better performance by enabling the next line:
#- /app/vendor
#- /srv/api/vendor
environment:
MERCURE_EXTRA_DIRECTIVES: demo
# See https://xdebug.org/docs/all_settings#mode
Expand Down

0 comments on commit 959a835

Please sign in to comment.