Niet weggooien van images 2

This commit is contained in:
Frank
2026-01-11 15:35:10 +01:00
parent 3b98e8650b
commit bc4f7a8c79
8 changed files with 47 additions and 48 deletions

2
.env
View File

@@ -44,7 +44,7 @@ MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
###< symfony/messenger ###
###> symfony/mailer ###
# Development: use Mailpit (docker-compose override provides service `mailer` on port 1025)
# Development: use Mailpit (docker compose override provides service `mailer` on port 1025)
MAILER_DSN=smtp://mailer:1025
# Production/Stage (uncomment and set SENDGRID_API_KEY in real env or secrets):
# MAILER_DSN=sendgrid+api://%env(SENDGRID_API_KEY)%

View File

@@ -16,9 +16,9 @@ This repository contains a Symfony 7.3 (PHP >= 8.5.1) application for a collabor
6. Run tests: `vendor/bin/phpunit`
- With Docker:
1. `docker-compose up -d`
1. `cd docker && docker compose up -d`
2. Install vendors inside the PHP container:
- `docker-compose exec php bash`
- `docker compose exec php bash`
- `composer install`
3. Initialize DB:
- `php bin/console doctrine:database:create --if-not-exists`
@@ -83,20 +83,14 @@ We use a Mercure hub (Docker service) to push server updates to browsers via Ser
Quick start (dev):
1. Start Docker stack:
```
docker-compose up -d
cd docker && docker compose up -d
```
This starts `mercure` at http://localhost:8090 and the app at http://localhost:8080.
2. Install PHP deps inside the PHP container if you haven't yet:
```
docker-compose exec php bash
docker compose exec php bash
composer install
```
3. Open the Game Hub page in your browser: http://localhost:8080/game
- The page subscribes to a demo topic and logs messages in the console.
4. Publish a test update (in the PHP container):
```
php bin/console app:mercure:publish
```
You should see a console log like `[Mercure] Update received: { ... }` on the Game Hub page.
Configuration:

View File

@@ -3,7 +3,7 @@
Use this index to quickly locate files and directories during development and in discussions.
## Top-Level
- compose.yaml / compose.override.yaml — Docker services.
- docker/compose.yaml / docker/compose.override.yaml — Docker services.
- docker/ — Docker build contexts and configs (php Dockerfile, nginx vhost).
- composer.json / composer.lock — Dependencies and scripts.
- importmap.php — Importmap configuration for JS dependencies.

View File

@@ -9,7 +9,7 @@ This app can run fully in Docker using docker compose with PHP-FPM, Nginx and My
- mailer (dev only via compose.override.yaml): Mailpit (SMTP/UI)
## Prerequisites
- Docker and Docker Compose (docker-compose)
- Docker and Docker Compose (docker compose)
## Usage
@@ -21,36 +21,42 @@ App will be served at http://localhost:8080
Alternatively (manual):
```
docker-compose up -d --build
cd docker
docker compose up -d --build
```
### 2) Install dependencies
The setup script already runs composer install. To run manually:
```
docker-compose exec php composer install
cd docker
docker compose exec php composer install
```
### 3) Prepare DB
The setup script already prepares the DB. To run manually:
```
docker-compose exec php php bin/console doctrine:database:create --if-not-exists
docker-compose exec php php bin/console doctrine:migrations:migrate -n
cd docker
docker compose exec php php bin/console doctrine:database:create --if-not-exists
docker compose exec php php bin/console doctrine:migrations:migrate -n
```
### 4) Run tests
```
docker-compose exec php vendor/bin/phpunit
cd docker
docker compose exec php vendor/bin/phpunit
```
### 5) Logs
```
docker-compose logs -f nginx
docker-compose logs -f php
cd docker
docker compose logs -f nginx
docker compose logs -f php
```
### 6) Stop
```
docker-compose down
cd docker
docker compose down
```
## Notes

View File

@@ -3,7 +3,7 @@ version: '3.7'
services:
php:
environment:
XDEBUG_MODE: "off"
XDEBUG_MODE: off
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:

View File

@@ -3,14 +3,14 @@ version: '3.7'
services:
php:
build:
context: .
dockerfile: docker/php/Dockerfile
context: ../
dockerfile: php/Dockerfile
args:
USER_ID: ${USER_ID:-1000}
GROUP_ID: ${GROUP_ID:-1000}
container_name: escapepage-php
volumes:
- ./:/var/www/html:delegated
- ../:/var/www/html:delegated
- /etc/hosts:/etc/hosts:ro
environment:
APP_ENV: ${APP_ENV:-dev}
@@ -24,14 +24,14 @@ services:
php-worker:
build:
context: .
dockerfile: docker/php/Dockerfile
context: ../
dockerfile: php/Dockerfile
args:
USER_ID: ${USER_ID:-1000}
GROUP_ID: ${GROUP_ID:-1000}
container_name: escapepage-php-worker
volumes:
- ./:/var/www/html:delegated
- ../:/var/www/html:delegated
- /etc/hosts:/etc/hosts:ro
environment:
APP_ENV: ${APP_ENV:-dev}
@@ -51,9 +51,9 @@ services:
- "8080:80"
- "8443:443"
volumes:
- ./:/var/www/html:ro
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
- ./docker/nginx/ssl:/etc/nginx/ssl:ro
- ../:/var/www/html:ro
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
- ./nginx/ssl:/etc/nginx/ssl:ro
- /etc/hosts:/etc/hosts:ro
depends_on:
- php
@@ -113,8 +113,8 @@ services:
start_period: 30s
command: ["--default-authentication-plugin=mysql_native_password", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"]
volumes:
- ./var/volumes/db:/var/lib/mysql:rw
- ./docker/mysql/init:/docker-entrypoint-initdb.d:ro
- ../var/volumes/db:/var/lib/mysql:rw
- ./mysql/init:/docker-entrypoint-initdb.d:ro
- /etc/hosts:/etc/hosts:ro
# Uncomment the two lines below if you need to access MySQL from your host (workbench, etc.)
ports:

View File

@@ -4,11 +4,10 @@ set -euo pipefail
# Script to completely restart the project as requested
echo "Stopping and removing containers..."
dc() { (cd "$(dirname "$0")/.." && docker-compose "$@"); }
dc down
docker compose -f compose.yaml -f compose.override.yaml --env-file ../.env down --remove-orphans
echo "Clearing Docker build cache..."
docker builder prune -f
docker builder prune -af
echo "Running setup script..."
"$(dirname "$0")/setup.sh" --no-build
./setup.sh --no-build

View File

@@ -18,17 +18,17 @@ set -euo pipefail
ROOT_DIR=$(cd "$(dirname "$0")"/.. && pwd)
DOCKER_DIR="$ROOT_DIR/docker"
# Determine the docker-compose command
if command -v docker-compose >/dev/null 2>&1; then
DOCKER_COMPOSE="docker-compose"
elif docker compose version >/dev/null 2>&1; then
if docker compose version >/dev/null 2>&1; then
DOCKER_COMPOSE="docker compose"
elif command -v docker-compose >/dev/null 2>&1; then
DOCKER_COMPOSE="docker-compose"
else
echo "Error: Neither 'docker-compose' nor 'docker compose' was found. Please install Docker Compose." >&2
exit 1
fi
# Helper to run docker compose from the project root
dc() { (cd "$ROOT_DIR" && $DOCKER_COMPOSE "$@"); }
# Helper to run docker compose from the docker directory
dc() { (cd "$DOCKER_DIR" && $DOCKER_COMPOSE -f compose.yaml -f compose.override.yaml --env-file ../.env "$@"); }
REBUILD=1
RECREATE=0
@@ -132,12 +132,12 @@ Open the app: $APP_URL
Mailpit (dev): $MAILPIT_URL
Common commands:
(cd "$ROOT_DIR" && $DOCKER_COMPOSE logs -f nginx)
(cd "$ROOT_DIR" && $DOCKER_COMPOSE logs -f php)
(cd "$ROOT_DIR" && $DOCKER_COMPOSE logs -f php-worker)
(cd "$ROOT_DIR" && $DOCKER_COMPOSE exec php bash)
(cd "$ROOT_DIR" && $DOCKER_COMPOSE exec php npm run watch)
(cd "$ROOT_DIR" && $DOCKER_COMPOSE down)
(cd "$DOCKER_DIR" && $DOCKER_COMPOSE logs -f nginx)
(cd "$DOCKER_DIR" && $DOCKER_COMPOSE logs -f php)
(cd "$DOCKER_DIR" && $DOCKER_COMPOSE logs -f php-worker)
(cd "$DOCKER_DIR" && $DOCKER_COMPOSE exec php bash)
(cd "$DOCKER_DIR" && $DOCKER_COMPOSE exec php npm run watch)
(cd "$DOCKER_DIR" && $DOCKER_COMPOSE down)
You can re-run this script any time. Use --no-build to skip rebuilding images.
EOT