From d70ada4c1bc10326273399238fd595a9eb799309 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 2 Apr 2026 02:20:11 +0000 Subject: [PATCH 1/2] Initial plan From 9921d4701a403f9448a398c4f5a77bfda4668482 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 2 Apr 2026 02:29:28 +0000 Subject: [PATCH 2/2] feat: complete Pimcore docker-compose project with proper architecture Agent-Logs-Url: https://github.com/Websoft9/docker-library/sessions/3c8d100b-1d6c-4306-8c1b-fcc5c3d9681b Co-authored-by: zhaojing1987 <7624828+zhaojing1987@users.noreply.github.com> --- apps/pimcore/.env | 32 ++++++---- apps/pimcore/Notes.md | 27 ++++++++- apps/pimcore/README.md | 10 ++-- apps/pimcore/docker-compose.yml | 102 ++++++++++++++++---------------- apps/pimcore/src/README.md | 19 ++++++ apps/pimcore/src/init.sh | 39 ++++++++++++ apps/pimcore/variables.json | 2 +- 7 files changed, 161 insertions(+), 70 deletions(-) create mode 100644 apps/pimcore/src/README.md create mode 100644 apps/pimcore/src/init.sh diff --git a/apps/pimcore/.env b/apps/pimcore/.env index 4c5536c7d..c6d1b7f6a 100644 --- a/apps/pimcore/.env +++ b/apps/pimcore/.env @@ -1,17 +1,25 @@ +W9_REPO=pimcore/pimcore +W9_DIST=community +# version refers to: https://github.com/pimcore/docker#image-flavors +W9_VERSION=php8.2-latest W9_POWER_PASSWORD=uQ8E1wVTzG8SOk3! -W9_NAME=pimcore -W9_REPO=pimcore/pimcore +# Environments which for user settings when create application +W9_HTTP_PORT_SET=9001 -# version refer to: https://github.com/pimcore/docker#image-flavors -W9_VERSION=php8.2-latest +#### -- Not allowed to edit below environments when recreate app based on existing data -- #### +W9_ID=pimcore +W9_HTTP_PORT=80 +W9_LOGIN_USER=admin +W9_LOGIN_PASSWORD=$W9_POWER_PASSWORD +W9_DB_EXPOSE=mariadb +W9_DB_VERSION=10.11 +W9_URL=internet_ip:$W9_HTTP_PORT_SET W9_NETWORK=websoft9 -W9_HTTP_PORT=9001 - +#### --------------------------------------------------------------------------------------- #### -W9_DB_PORT=3306 -W9_DB_MYSQL_VERSION=5.7 -W9_DB_MYSQL_PORT=3306 -W9_DB_MYSQL_PASSWORD=$W9_POWER_PASSWORD -W9_DB_MYSQL_NAME=$W9_NAME -W9_DB_MYSQL_USER=$W9_NAME \ No newline at end of file +# Pimcore database connection +PIMCORE_DB_HOST=$W9_ID-mariadb +PIMCORE_DB_NAME=$W9_ID +PIMCORE_DB_USER=$W9_ID +PIMCORE_DB_PASSWORD=$W9_POWER_PASSWORD \ No newline at end of file diff --git a/apps/pimcore/Notes.md b/apps/pimcore/Notes.md index 96927c076..a10e801c5 100644 --- a/apps/pimcore/Notes.md +++ b/apps/pimcore/Notes.md @@ -1,3 +1,28 @@ # Pimcore -Can not used, need improve \ No newline at end of file +## Architecture + +This stack uses 3 long-running containers + 1 initialization container: + +- **nginx**: Web server (nginx:stable-alpine), handles HTTP requests and proxies PHP to the `php` service +- **php**: PHP-FPM + background workers (`pimcore/pimcore:php8.2-supervisord-latest`) +- **mariadb**: MariaDB 10.11 database +- **init**: One-time setup container (`pimcore/pimcore:php8.2-latest`) that runs on first startup to install Pimcore via Composer and configure the database + +## First Startup + +On first `docker compose up -d`, the `init` container will: +1. Run `composer create-project pimcore/skeleton` to download Pimcore +2. Run `vendor/bin/pimcore-install` to initialize the database and create the admin user + +This step can take **5–15 minutes** depending on network speed. The `php` and `nginx` containers will return errors until initialization completes. Monitor progress with: + +```bash +docker logs -f pimcore-init +``` + +## References + +- Official image: https://hub.docker.com/r/pimcore/pimcore +- Docker setup docs: https://github.com/pimcore/docker +- Pimcore skeleton: https://github.com/pimcore/skeleton \ No newline at end of file diff --git a/apps/pimcore/README.md b/apps/pimcore/README.md index 4f8466523..d99957d79 100644 --- a/apps/pimcore/README.md +++ b/apps/pimcore/README.md @@ -1,6 +1,6 @@ -# Pimcore on Docker +# Pimcore on Docker -This is an **[Docker Compose template](https://github.com/Websoft9/docker-library)** powered by [Websoft9](https://www.websoft9.com) based on Docker for Pimcore : +This is an **[Docker Compose template](https://github.com/Websoft9/docker-library)** powered by [Websoft9](https://www.websoft9.com) based on Docker for Pimcore: - community: php8.2-latest @@ -17,10 +17,10 @@ The following are the minimal [recommended requirements](https://github.com/pimc ## Install -You can install this Pimcore by [How to use it?](https://github.com/Websoft9/docker-library#how-to-use-it). +You can install this Pimcore by [How to use it?](https://github.com/Websoft9/docker-library#how-to-use-it). -If you want use Pimcore with **Websoft9 Business Support** free, you can [subscribe Pimcore ](https://www.websoft9.com/apps) on Cloud platform +If you want use Pimcore with **Websoft9 Business Support** free, you can [subscribe Pimcore](https://www.websoft9.com/apps) on Cloud platform ## Documentation -[Pimcore Administrator Guide](https://support.websoft9.com/docs/pimcore) powered by Websoft9 \ No newline at end of file +[Pimcore Administrator Guide](https://support.websoft9.com/docs/pimcore) powered by Websoft9 \ No newline at end of file diff --git a/apps/pimcore/docker-compose.yml b/apps/pimcore/docker-compose.yml index 0f744e155..508f812a4 100644 --- a/apps/pimcore/docker-compose.yml +++ b/apps/pimcore/docker-compose.yml @@ -1,79 +1,79 @@ -# docs1: https://pimcore.com/docs/platform/Pimcore/Getting_Started/Installation/Docker_Based_Installation/ -# docs2: https://github.com/pimcore/docker +# image,docs: https://hub.docker.com/r/pimcore/pimcore +# github: https://github.com/pimcore/skeleton version: '3.8' -services: - pimcore: + +services: + init: image: $W9_REPO:$W9_VERSION - container_name: $W9_NAME - restart: unless-stopped + container_name: $W9_ID-init + restart: on-failure env_file: .env - ports: - - $W9_HTTP_PORT:80 + volumes: + - pimcore:/var/www/html + - ./src/init.sh:/data/init.sh + depends_on: + mariadb: + condition: service_healthy + command: ["bash", "/data/init.sh"] + + php: + image: pimcore/pimcore:php8.2-supervisord-latest + container_name: $W9_ID + restart: unless-stopped logging: driver: "json-file" options: - max-file: "5" - max-size: 10m + max-file: "5" + max-size: 10m + env_file: .env volumes: - pimcore:/var/www/html + - ./src/supervisord.conf:/etc/supervisor/conf.d/pimcore.conf:ro environment: - PIMCORE_ENVIRONMENT: dev - MYSQL_HOST: $W9_NAME-db - MYSQL_DATABASE: $W9_DB_MYSQL_NAME - MYSQL_USER: $W9_DB_MYSQL_USER - MYSQL_PASSWORD: $W9_DB_MYSQL_PASSWORD - - supervisord: - #user: '1000:1000' # set to your uid:gid - image: pimcore/pimcore:php8.2-supervisord-latest - container_name: $W9_NAME-supervisord + # DATABASE_URL is built from PIMCORE_DB_* variables in .env (Symfony DSN format for PHP runtime) + DATABASE_URL: "mysql://${PIMCORE_DB_USER}:${PIMCORE_DB_PASSWORD}@${PIMCORE_DB_HOST}:3306/${PIMCORE_DB_NAME}" + APP_ENV: prod depends_on: - db: - condition: service_healthy - volumes: - - .:/var/www/html - - ./src/supervisord.conf:/etc/supervisor/conf.d/pimcore.conf:ro + mariadb: + condition: service_healthy nginx: image: nginx:stable-alpine + container_name: $W9_ID-nginx + restart: unless-stopped ports: - - "$W9_HTTP_PORT:80" + - $W9_HTTP_PORT_SET:$W9_HTTP_PORT volumes: - - .:/var/www/html:ro + - pimcore:/var/www/html:ro - ./src/nginx.conf:/etc/nginx/conf.d/default.conf:ro depends_on: - php - mysql: - image: mysql:$W9_DB_MYSQL_VERSION - container_name: $W9_NAME-db + mariadb: + image: mariadb:$W9_DB_VERSION + container_name: $W9_ID-mariadb restart: unless-stopped - ports: - - ${W9_DB_MYSQL_PORT}:3306 command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --innodb_log_buffer_size=30M volumes: - - mysql_data:/var/lib/mysql + - mariadb:/var/lib/mysql environment: - MYSQL_DATABASE: $W9_DB_MYSQL_NAME - MYSQL_USER: $W9_DB_MYSQL_USER - MYSQL_PASSWORD: $W9_DB_MYSQL_PASSWORD - MYSQL_ROOT_PASSWORD: $W9_DB_MYSQL_PASSWORD + MARIADB_DATABASE: $W9_ID + MARIADB_USER: $W9_ID + MARIADB_PASSWORD: $W9_POWER_PASSWORD + MARIADB_ROOT_PASSWORD: $W9_POWER_PASSWORD + healthcheck: + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] + interval: 10s + timeout: 5s + retries: 10 + start_period: 30s - redis: - image: redis:alpine - container_name: $W9_NAME-redis - command: [ redis-server, --maxmemory 128mb, --maxmemory-policy volatile-lru, --save "" ] - - +volumes: + pimcore: + mariadb: networks: default: - name: ${W9_NETWORK} - external: true - -volumes: - pimcore: - driver: local - mysql_data: - driver: local \ No newline at end of file + name: $W9_NETWORK + external: true \ No newline at end of file diff --git a/apps/pimcore/src/README.md b/apps/pimcore/src/README.md new file mode 100644 index 000000000..9e8c9d07d --- /dev/null +++ b/apps/pimcore/src/README.md @@ -0,0 +1,19 @@ +# src/ - Pimcore Configuration Files + +## nginx.conf +Custom Nginx configuration for serving Pimcore. Handles: +- Static asset serving with cache headers +- PHP-FPM proxy to the `php` service on port 9000 +- Pimcore-specific rewrite rules (cache-buster, protected assets) +- Static page cache integration + +## supervisord.conf +Supervisord configuration for Pimcore background processes: +- `messenger:consume` – processes async jobs (image optimization, maintenance tasks) +- `maintenance` – runs periodic Pimcore maintenance commands + +## init.sh +First-run initialization script executed by the `init` container: +1. Installs the Pimcore skeleton project via Composer +2. Runs `pimcore-install` to initialize the database and admin user +3. Creates a `.installed` lock file to skip re-initialization on subsequent startups diff --git a/apps/pimcore/src/init.sh b/apps/pimcore/src/init.sh new file mode 100644 index 000000000..db7cbc3f0 --- /dev/null +++ b/apps/pimcore/src/init.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -e + +echo "=== Pimcore Initialization ===" + +# Check if Pimcore is already installed +if [ -f /var/www/html/.installed ]; then + echo "Pimcore already initialized, skipping..." + exit 0 +fi + +cd /var/www/html + +# Install Pimcore skeleton if composer.json is missing +if [ ! -f /var/www/html/composer.json ]; then + echo "Creating Pimcore project via composer..." + composer create-project pimcore/skeleton /tmp/pimcore-install --no-interaction + cp -rf /tmp/pimcore-install/. /var/www/html/ + rm -rf /tmp/pimcore-install +fi + +# Install Pimcore (creates database tables and admin user) +echo "Running pimcore-install..." +php vendor/bin/pimcore-install \ + --admin-username="${W9_LOGIN_USER}" \ + --admin-password="${W9_LOGIN_PASSWORD}" \ + --mysql-host-socket="${PIMCORE_DB_HOST}" \ + --mysql-username="${PIMCORE_DB_USER}" \ + --mysql-password="${PIMCORE_DB_PASSWORD}" \ + --mysql-database="${PIMCORE_DB_NAME}" \ + --no-interaction + +# Fix file permissions for web server +chown -R www-data:www-data /var/www/html/var /var/www/html/public 2>/dev/null || echo "Warning: Could not set permissions on var/public directories (non-fatal)" + +# Mark as installed to skip on subsequent startups +touch /var/www/html/.installed + +echo "=== Pimcore Initialization Complete ===" diff --git a/apps/pimcore/variables.json b/apps/pimcore/variables.json index c5dba3b1c..361d8f8ef 100644 --- a/apps/pimcore/variables.json +++ b/apps/pimcore/variables.json @@ -1,6 +1,6 @@ { "name": "pimcore", - "trademark": "Pimcore ", + "trademark": "Pimcore", "release": false, "fork_url": "https://github.com/pimcore/docker", "version_from": "https://hub.docker.com/r/pimcore/pimcore/tags",