Compare commits
3 Commits
3737e8f581
...
314e16d4bf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
314e16d4bf | ||
|
|
59c1d97d84 | ||
|
|
3de1e907f2 |
@@ -5,7 +5,7 @@ services:
|
|||||||
php:
|
php:
|
||||||
build:
|
build:
|
||||||
context: ..
|
context: ..
|
||||||
dockerfile: php/Dockerfile
|
dockerfile: docker/php/Dockerfile
|
||||||
container_name: escapepage-php
|
container_name: escapepage-php
|
||||||
volumes:
|
volumes:
|
||||||
- ../:/var/www/html:delegated
|
- ../:/var/www/html:delegated
|
||||||
@@ -18,6 +18,23 @@ services:
|
|||||||
- backend
|
- backend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
|
php-worker:
|
||||||
|
build:
|
||||||
|
context: ..
|
||||||
|
dockerfile: docker/php/Dockerfile
|
||||||
|
container_name: escapepage-php-worker
|
||||||
|
volumes:
|
||||||
|
- ../:/var/www/html:delegated
|
||||||
|
environment:
|
||||||
|
APP_ENV: dev
|
||||||
|
depends_on:
|
||||||
|
- database
|
||||||
|
- mercure
|
||||||
|
command: ["php", "bin/console", "messenger:consume", "async", "-vv"]
|
||||||
|
networks:
|
||||||
|
- backend
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
image: nginx:1.29.4-alpine
|
image: nginx:1.29.4-alpine
|
||||||
container_name: escapepage-nginx
|
container_name: escapepage-nginx
|
||||||
|
|||||||
@@ -1,11 +1,20 @@
|
|||||||
FROM php:8.5.1-fpm-alpine3.23
|
FROM php:8.3-fpm-alpine
|
||||||
|
|
||||||
# Install system deps
|
# Install system deps
|
||||||
RUN apk add --no-cache bash git icu-dev libzip-dev oniguruma-dev
|
RUN apk add --no-cache \
|
||||||
|
bash \
|
||||||
|
git \
|
||||||
|
icu-dev \
|
||||||
|
libzip-dev \
|
||||||
|
oniguruma-dev \
|
||||||
|
g++ \
|
||||||
|
make \
|
||||||
|
nodejs \
|
||||||
|
npm
|
||||||
|
|
||||||
# Install PHP extensions
|
# Install PHP extensions
|
||||||
RUN docker-php-ext-configure intl \
|
RUN docker-php-ext-configure intl \
|
||||||
&& docker-php-ext-install -j$(nproc) intl pdo pdo_mysql opcache
|
&& docker-php-ext-install -j$(nproc) intl pdo pdo_mysql opcache zip
|
||||||
|
|
||||||
# Install composer
|
# Install composer
|
||||||
ENV COMPOSER_ALLOW_SUPERUSER=1 \
|
ENV COMPOSER_ALLOW_SUPERUSER=1 \
|
||||||
@@ -13,7 +22,7 @@ ENV COMPOSER_ALLOW_SUPERUSER=1 \
|
|||||||
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
# Configure PHP
|
# Configure PHP
|
||||||
COPY php.ini $PHP_INI_DIR/conf.d/zz-custom.ini
|
COPY docker/php/php.ini $PHP_INI_DIR/conf.d/zz-custom.ini
|
||||||
|
|
||||||
WORKDIR /var/www/html
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
|
|||||||
@@ -66,12 +66,15 @@ dc up "${BUILD_ARGS[@]}"
|
|||||||
# Helper to run commands in php container
|
# Helper to run commands in php container
|
||||||
pexec() { dc exec -T php "$@"; }
|
pexec() { dc exec -T php "$@"; }
|
||||||
|
|
||||||
# Wait for database to be healthy (mariadb)
|
# Wait for database to be healthy (mariadb/mysql)
|
||||||
printf "Waiting for database to be healthy..."
|
printf "Waiting for database to be healthy..."
|
||||||
# Use docker inspect health status
|
# Use docker inspect health status
|
||||||
DB_HEALTH=""
|
DB_HEALTH=""
|
||||||
for i in {1..60}; do
|
for i in {1..60}; do
|
||||||
DB_HEALTH=$(docker inspect -f '{{.State.Health.Status}}' "$(docker ps --filter name=_database_ --format '{{.ID}}' | head -n1)" 2>/dev/null || true)
|
DB_ID=$(dc ps -q database 2>/dev/null || true)
|
||||||
|
if [ -n "$DB_ID" ]; then
|
||||||
|
DB_HEALTH=$(docker inspect -f '{{.State.Health.Status}}' "$DB_ID" 2>/dev/null || true)
|
||||||
|
fi
|
||||||
if [ "$DB_HEALTH" = "healthy" ]; then
|
if [ "$DB_HEALTH" = "healthy" ]; then
|
||||||
echo " OK"
|
echo " OK"
|
||||||
break
|
break
|
||||||
@@ -79,7 +82,7 @@ for i in {1..60}; do
|
|||||||
printf "."
|
printf "."
|
||||||
sleep 2
|
sleep 2
|
||||||
if [ "$i" -eq 60 ]; then
|
if [ "$i" -eq 60 ]; then
|
||||||
echo "\nWarning: database health check not healthy yet, continuing anyway."
|
echo -e "\nWarning: database health check not healthy yet, continuing anyway."
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -100,11 +103,23 @@ if grep -q '^APP_SECRET=$' "$ROOT_DIR/.env" 2>/dev/null; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Prepare DB
|
# Prepare DB
|
||||||
pexec php bin/console doctrine:database:create --if-not-exists || true
|
echo "Creating database if it doesn't exist..."
|
||||||
pexec php bin/console doctrine:migrations:migrate -n || true
|
pexec php bin/console doctrine:database:create --if-not-exists
|
||||||
|
echo "Running migrations..."
|
||||||
|
pexec php bin/console doctrine:migrations:migrate -n
|
||||||
|
|
||||||
# Import JS deps (Importmap/Asset Mapper)
|
# Import JS deps (Importmap/Asset Mapper)
|
||||||
pexec php bin/console importmap:install || true
|
if [ -f "$ROOT_DIR/importmap.php" ]; then
|
||||||
|
pexec php bin/console importmap:install || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build assets if using Webpack Encore
|
||||||
|
if [ -f "$ROOT_DIR/package.json" ]; then
|
||||||
|
echo "Installing npm dependencies..."
|
||||||
|
pexec npm install
|
||||||
|
echo "Building assets..."
|
||||||
|
pexec npm run build
|
||||||
|
fi
|
||||||
|
|
||||||
APP_URL=http://localhost:8080
|
APP_URL=http://localhost:8080
|
||||||
MAILPIT_URL=http://localhost:8025
|
MAILPIT_URL=http://localhost:8025
|
||||||
@@ -117,10 +132,12 @@ Open the app: $APP_URL
|
|||||||
Mailpit (dev): $MAILPIT_URL
|
Mailpit (dev): $MAILPIT_URL
|
||||||
|
|
||||||
Common commands:
|
Common commands:
|
||||||
(cd docker && $DOCKER_COMPOSE logs -f nginx)
|
(cd "$DOCKER_DIR" && $DOCKER_COMPOSE logs -f nginx)
|
||||||
(cd docker && $DOCKER_COMPOSE logs -f php)
|
(cd "$DOCKER_DIR" && $DOCKER_COMPOSE logs -f php)
|
||||||
(cd docker && $DOCKER_COMPOSE exec php bash)
|
(cd "$DOCKER_DIR" && $DOCKER_COMPOSE logs -f php-worker)
|
||||||
(cd docker && $DOCKER_COMPOSE down)
|
(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.
|
You can re-run this script any time. Use --no-build to skip rebuilding images.
|
||||||
EOT
|
EOT
|
||||||
|
|||||||
Reference in New Issue
Block a user