Local development environment – Dev container 🚀

The Dev Container streamlines onboarding and enforces consistent builds. It leverages VS Code’s Remote – Containers extension, Docker Compose, and Laravel Sail to provide an isolated, ready-to-code environment for all developers.

devcontainer.json configuration

This JSON file instructs VS Code how to spin up the containerized workspace. It lives at .devcontainer/devcontainer.json .

{
  "name": "Prep Network EA",
  "dockerComposeFile": ["./docker-compose.yml"],
  "service": "laravel.test",
  "workspaceFolder": "/var/www/html",
  "customizations": {
    "vscode": {
      "settings": { /* VS Code settings */ },
      "extensions": [ /* Pre-installed extensions */ ]
    }
  },
  "remoteUser": "sail",
  "postCreateCommand": "chown -R 1000:1000 /var/www/html 2>/dev/null || true",
  "postStartCommand": "rm -f nohup.out && nohup bash -c 'npm install && npm run dev &'"
}

Key options

Option Purpose Example
name Human-readable container name "Prep Network EA"
dockerComposeFile Paths to Compose files ["./docker-compose.yml"]
service Primary service to attach VS Code to "laravel.test"
workspaceFolder Mount point for project code "/var/www/html"
remoteUser Default shell user inside the container "sail"
postCreateCommand Runs once after container creation chown -R 1000:1000 /var/www/html ...
postStartCommand Runs after the container and services start npm install && npm run dev

VS Code customizations

The container pre-installs settings and a curated extension list to enforce code style and productivity.

Settings

Setting Description
files.associations.blade.php Associate .blade.php with Blade syntax
editor.indentSize Use project’s Tab Size
files.trimTrailingWhitespace Remove trailing spaces on save
[php].editor.defaultFormatter wongjn.php-sniffer for PHP formatting
[javascript].editor.defaultFormatter esbenp.prettier-vscode
[html].editor.defaultFormatter esbenp.prettier-vscode
intelephense.stubs Stubs for core PHP extensions
git.autofetch & git.enableSmartCommit Smart Git integration
editor.formatOnSave Auto-format on save
phpSniffer.executablesFolder Path to PHP-CS-Fixer / PHPCS

Extensions

  • GitHub Copilot & Copilot-Chat
  • bmewburn.vscode-intelephense-client
  • esbenp.prettier-vscode
  • file-icons.file-icons
  • MehediDracula.php-namespace-resolver
  • bradlc.vscode-tailwindcss
  • wongjn.php-sniffer
  • apility.beautify-blade
  • onecentlin.laravel-extension-pack
  • eamodio.gitlens
  • open-southeners.laravel-pint

Docker Compose – laravel.test service 🐳

The Dev Container spins up services via docker-compose.yml at the project root .

services:
  laravel.test:
    build:
      context: ./vendor/laravel/sail/runtimes/8.4
      dockerfile: Dockerfile
      args:
        WWWGROUP: "${WWWGROUP}"
    image: sail-8.4/app
    extra_hosts:
      - "host.docker.internal:host-gateway"
    ports:
      - "${APP_PORT:-8000}:80"
      - "${VITE_PORT:-5173}:${VITE_PORT:-5173}"
    environment:
      WWWUSER: "${WWWUSER}"
      LARAVEL_SAIL: 1
      XDEBUG_MODE: "${SAIL_XDEBUG_MODE:-off}"
      XDEBUG_CONFIG: "${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}"
      IGNITION_LOCAL_SITES_PATH: "${PWD}"
    volumes:
      - ".:/var/www/html"
    networks:
      - sail
      - lando_bridge_network
    depends_on:
      - mysql
      - redis
      - mailpit
    env_file:
      - .env

Highlights:

  • Build context uses Laravel Sail’s runtime for PHP 8.4.
  • Ports map host 8000→80 and Vite port for hot reload.
  • Volumes mount code into /var/www/html for live edits.
  • Dependencies on MySQL, Redis, and Mailpit guarantee services are ready.

Workflow diagram

Below is the simplified startup flow when opening in VS Code:

flowchart LR
  A[Open in VS Code] --> B[Read .devcontainer/devcontainer.json]
  B --> C[Compose up laravel.test & deps]
  C --> D[postCreate: chown workspace]
  D --> E[postStart: npm install & npm run dev]
  E --> F[Environment Ready]

Important prerequisites

{
  "title": "Prerequisites",
  "content": "Ensure Docker is running and the VS Code Remote - Containers extension is installed."
}