Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "BeWelcome Rox (Docker Master)",
"dockerComposeFile": [
"../docker-compose.yml",
"../docker-compose.override.yml.dist"
],
"service": "php",
"workspaceFolder": "/srv/bewelcome",
"overrideCommand": false,
"forwardPorts": [80, 1080, 9306, 9308],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The seed SQL files (languages.sql, words.sql) are not in the repo — they are downloaded from downloads.bewelcome.org and decompressed by make install. A fresh devcontainer skips this entirely, so the imports are silently skipped (if [ -f ... ] guard passes quietly) and the language/words tables end up empty, breaking locale switching and member language preferences.

A postCreateCommand is needed, for example:

"postCreateCommand": "curl https://downloads.bewelcome.org/for_developers/rox_test_db/languages.sql.bz2 -o docker/db/languages.sql.bz2 && curl https://downloads.bewelcome.org/for_developers/rox_test_db/words.sql.bz2 -o docker/db/words.sql.bz2 && bunzip2 --force docker/db/languages.sql.bz2 docker/db/words.sql.bz2"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macOS + Rancher Desktop note: forwardPorts causes port conflicts on macOS with Rancher Desktop (and likely other non-Docker-Desktop runtimes). Rancher exposes container ports via SSH tunnelling from its Lima VM, and VS Code's forwardPorts creates a competing localhost:PORT listener on top of that. Because the localhost-specific binding wins over the SSH tunnel's wildcard bind, connections get routed into the php container's localhost instead of the correct mailer/web container — and hang.

Workaround tested on macOS + Rancher Desktop: remove forwardPorts entirely. Ports with host mappings in the compose files are auto-detected by VS Code's Ports panel anyway; portsAttributes labels still apply. The forwardPorts array is only needed for ports that are not host-mapped in the compose file.

Works fine on WSL/Docker Desktop as-is — this is a macOS-specific Rancher Desktop behaviour. Worth adding a note to the README.

"portsAttributes": {
"80": {
"label": "BeWelcome App (Nginx)",
"onAutoForward": "openBrowser"
},
"1080": {
"label": "MailPit Web UI",
"onAutoForward": "notify"
},
"9306": {
"label": "Manticore MySQL protocol",
"onAutoForward": "silent"
},
"9308": {
"label": "Manticore HTTP API",
"onAutoForward": "silent"
}
},
"hostRequirements": {
"cpus": 2,
"memory": "4gb",
"storage": "32gb"
},
"customizations": {
"vscode": {
"extensions": [
"bmewburn.vscode-intelephense-client",
"xdebug.php-debug",
"symfony-vscode.symfony-vscode",
"bradlc.vscode-tailwindcss",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"mikestead.dotenv",
"ms-azuretools.vscode-docker",
"GitHub.vscode-pull-request-github"
],
"settings": {
"php.suggest.basic": false,
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[php]": {
"editor.defaultFormatter": "bmewburn.vscode-intelephense-client"
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: phpVersion should be "8.2.0" to match the actual PHP version in the Docker image (the Dockerfile builds on PHP 8.2). Setting it to 8.3.0 will make Intelephense flag valid 8.2 code as errors.

"intelephense.environment.phpVersion": "8.3.0",
"intelephense.files.maxSize": 5000000
}
}
}
}
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* text=auto
*.sh text eol=lf
bin/console text eol=lf
.env text eol=lf
12 changes: 11 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,17 @@ FROM bewelcome_php AS bewelcome_php_dev
# build for production
ARG NODE_ENV=production

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

RUN set -eux; \
apk add --no-cache \
make \
mysql-client
mysql-client \
libstdc++ \
gcompat \
bash \
nodejs \
procps; \
install-php-extensions xdebug

COPY docker/php/conf.d/bewelcome.xdebug.ini $PHP_INI_DIR/conf.d/xdebug.ini
8 changes: 0 additions & 8 deletions behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ default:
suites:
default:
contexts:
- 'Alex\MailCatcher\Behat\MailCatcherContext': ~
- 'App\Tests\Behat\DatabaseContext': ~
- 'App\Tests\Behat\RefreshTokenContext': ~
- 'App\Tests\Behat\SecurityContext': ~
Expand All @@ -19,11 +18,4 @@ default:
symfony: ~
'Behatch\Extension': ~
'FriendsOfBehat\SymfonyExtension': ~
'Alex\MailCatcher\Behat\MailCatcherExtension\Extension':
url: http://mailcatcher
purge_before_scenario: true

localhost:
extensions:
'Alex\MailCatcher\Behat\MailCatcherExtension\Extension':
url: http://localhost:1080
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
"symfony/symfony": "*"
},
"require-dev": {
"alexandresalome/mailcatcher": "^1.3",
"behat/behat": "^3.7",
"behatch/contexts": "^3.3",
"dama/doctrine-test-bundle": "^6.3",
Expand Down
155 changes: 5 additions & 150 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion config/packages/framework.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ framework:
#serializer: { enable_annotations: true }
default_locale: "en"
trusted_hosts: ~
trusted_proxies: '%env(SYMFONY_TRUSTED_PROXIES)%'
trusted_proxies: '%env(string:default::SYMFONY_TRUSTED_PROXIES)%'
trusted_headers:
- x-forwarded-for
- x-forwarded-host
Expand Down
3 changes: 3 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ services:

# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App\Form\DataTransformer\:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

App\Form\DataTransformer\ is already covered by the App\: catch-all below — DataTransformer is not in the exclude list, so this explicit registration is a no-op. It is also unrelated to the devcontainer work. If it fixes a real bug, it deserves its own PR with an explanation.

resource: '../src/Form/DataTransformer/*'

App\:
resource: '../src/*'
exclude: '../src/{DependencyInjection,Entity,Migrations,Model/MemberDataExtractor/DoctrineExtractor.php,Twig,Tests,Kernel.php}'
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.override.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
# Not used by the beta or production stacks.
services:
php:
build:
target: bewelcome_php_dev

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither web (nginx) nor mailer (MailPit) exposes ports to the host. VS Code's forwardPorts forwards from inside the primary service (php), which doesn't listen on 80 or 1080, so both services are unreachable in the browser locally. Codespaces auto-scans all containers and handles this more gracefully, but local VS Code DevContainers will not forward these ports without explicit mappings.

Please add:

  web:
    ports:
      - "80:80"
  mailer:
    ports:
      - "1080:80"

volumes:
- .:/srv/bewelcome:rw,cached
- ./docker/php/conf.d/bewelcome.dev.ini:/usr/local/etc/php/conf.d/bewelcome.ini
# if you develop on Linux, you may use a bind-mounted host directory instead
# - ./var:/srv/bewelcome/var:rw

web:
ports:
- "80:80"
volumes:
- ./public:/srv/bewelcome/public:ro

mailer:
ports:
- "1080:80"
5 changes: 4 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ services:
- ./data:/var/lib/manticore

mailer:
image: tophfr/mailcatcher
image: axllent/mailpit
environment:
MP_SMTP_BIND_ADDR: "0.0.0.0:25"
MP_UI_BIND_ADDR: "0.0.0.0:80"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MailPit's web UI is bound to port 80 here, but devcontainer.json lists port 1080 as "MailPit Web UI". These disagree — a developer hitting localhost:1080 will get nothing.

Either change this to MP_UI_BIND_ADDR: "0.0.0.0:1080", or keep port 80 internally and map host 1080 → container 80 in docker-compose.override.yml.dist (see that file's comment).


volumes:
db-data: {}
6 changes: 6 additions & 0 deletions docker/php/conf.d/bewelcome.xdebug.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
; Xdebug configuration for development
; Disabled by default for performance. To enable, you can set XDEBUG_MODE=debug
xdebug.mode=off
xdebug.client_host=host.docker.internal
xdebug.start_with_request=yes
xdebug.discover_client_host=1
Loading
Loading