Skip to content
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

Add Devcontainer support #2488

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 30 additions & 0 deletions .devcontainer/compose.devcontainer.yaml
@@ -0,0 +1,30 @@
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:

# Overrides default command so things don't shut down after the process ends.
# command: /bin/sh -c "while sleep 1000; do :; done"
42 changes: 42 additions & 0 deletions .devcontainer/devcontainer.json
@@ -0,0 +1,42 @@
// 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": {}

// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
}
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