Skip to content

Commit 959a835

Browse files
committed
Devcontainer
1 parent 4bf748a commit 959a835

7 files changed

Lines changed: 139 additions & 7 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
version: '3.4'
2+
services:
3+
# Update this to the name of the service you want to work with in your docker-compose.yml file
4+
php:
5+
# Uncomment if you want to override the service's Dockerfile to one in the .devcontainer
6+
# folder. Note that the path of the Dockerfile and context is relative to the *primary*
7+
# docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile"
8+
# array). The sample below assumes your primary file is in the root of your project.
9+
#
10+
# build:
11+
# context: .
12+
# dockerfile: .devcontainer/Dockerfile
13+
14+
volumes:
15+
# Update this to wherever you want VS Code to mount the folder of your project
16+
- .:/srv:cached
17+
18+
environment:
19+
# See https://xdebug.org/docs/all_settings#mode
20+
XDEBUG_MODE: debug
21+
# Enable the step debugger
22+
XDEBUG_SESSION: 1
23+
# Override api/docker/php/conf.d/app.dev.ini
24+
XDEBUG_CONFIG: "client_host=localhost"
25+
26+
# This Unset APP_ENV to allow Symfony to use the value from .env so you can set it on the fly.
27+
# APP_ENV:
28+
29+
# Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust.
30+
# cap_add:
31+
# - SYS_PTRACE
32+
# security_opt:
33+
# - seccomp:unconfined
34+
35+
# Overrides default command so things don't shut down after the process ends.
36+
# command: /bin/sh -c "while sleep 1000; do :; done"

.devcontainer/devcontainer.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
3+
{
4+
"name": "API Platform Devcontainer",
5+
6+
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
7+
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
8+
"dockerComposeFile": [
9+
"../compose.yaml",
10+
"../compose.override.yaml",
11+
"compose.devcontainer.yaml"
12+
],
13+
14+
// The 'service' property is the name of the service for the container that VS Code should
15+
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
16+
"service": "php",
17+
18+
// The optional 'workspaceFolder' property is the path VS Code should open by default when
19+
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
20+
"workspaceFolder": "/srv",
21+
22+
// Features to add to the dev container. More info: https://containers.dev/features.
23+
// "features": {},
24+
25+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
26+
// "forwardPorts": [],
27+
28+
// Uncomment the next line if you want start specific services in your Docker Compose config.
29+
// "runServices": [],
30+
31+
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
32+
// "shutdownAction": "none",
33+
34+
// Uncomment the next line to run commands after the container is created.
35+
// "postCreateCommand": ". .devcontainer/install-dev-tools.sh",
36+
37+
// Configure tool-specific properties.
38+
"customizations": {
39+
"vscode": {
40+
"extensions": [
41+
"xdebug.php-debug"
42+
]
43+
}
44+
}
45+
46+
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
47+
// "remoteUser": "devcontainer"
48+
}

.vscode/launch.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Listen for Xdebug",
9+
"type": "php",
10+
"request": "launch",
11+
"port": 9003
12+
},
13+
{
14+
"name": "Launch currently open script",
15+
"type": "php",
16+
"request": "launch",
17+
"program": "${file}",
18+
"cwd": "${fileDirname}",
19+
"port": 0,
20+
"runtimeArgs": [
21+
"-dxdebug.start_with_request=yes"
22+
],
23+
"env": {
24+
"XDEBUG_MODE": "debug,develop",
25+
"XDEBUG_CONFIG": "client_port=${port}"
26+
}
27+
},
28+
{
29+
"name": "Launch Built-in web server",
30+
"type": "php",
31+
"request": "launch",
32+
"runtimeArgs": [
33+
"-dxdebug.mode=debug",
34+
"-dxdebug.start_with_request=yes",
35+
"-S",
36+
"localhost:0"
37+
],
38+
"program": "",
39+
"cwd": "${workspaceRoot}",
40+
"port": 9003,
41+
"serverReadyAction": {
42+
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
43+
"uriFormat": "http://localhost:%s",
44+
"action": "openExternally"
45+
}
46+
}
47+
]
48+
}

api/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ FROM dunglas/frankenphp:1-php8.3 AS frankenphp_upstream
1515
# Base FrankenPHP image
1616
FROM frankenphp_upstream AS frankenphp_base
1717

18-
WORKDIR /app
18+
WORKDIR /srv/api
1919

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

6060
ENV APP_ENV=dev XDEBUG_MODE=off
61-
VOLUME /app/var/
61+
VOLUME /srv/api/var/
6262

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

api/frankenphp/Caddyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
}
2727
}
2828

29-
root * /app/public
29+
root * /srv/api/public
3030
encode {
3131
zstd
3232
br

api/frankenphp/conf.d/app.prod.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
opcache.preload_user = root
2-
opcache.preload = /app/config/preload.php
2+
opcache.preload = /srv/api/config/preload.php

compose.override.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ services:
55
context: ./api
66
target: frankenphp_dev
77
volumes:
8-
- ./api:/app
9-
- /app/var
8+
- ./api:/srv/api
9+
- /srv/api/var
1010
- ./api/frankenphp/Caddyfile:/etc/caddy/Caddyfile:ro
1111
- ./api/frankenphp/conf.d/app.dev.ini:/usr/local/etc/php/conf.d/app.dev.ini:ro
1212
# If you develop on Mac or Windows you can remove the vendor/ directory
1313
# from the bind-mount for better performance by enabling the next line:
14-
#- /app/vendor
14+
#- /srv/api/vendor
1515
environment:
1616
MERCURE_EXTRA_DIRECTIVES: demo
1717
# See https://xdebug.org/docs/all_settings#mode

0 commit comments

Comments
 (0)