reward icon indicating copy to clipboard operation
reward copied to clipboard

php-fpm Error and Incorrect reward info Status for Non-PHP Node.js Environment

Open zaheerbadi opened this issue 7 months ago • 1 comments

## Bug Report: `php-fpm` Error and Incorrect `reward info` Status for Node.js Environment

### Description
When running `reward env up` for a Node.js + MySQL environment (non-PHP), I encounter the error: `service "php-fpm" has neither an image nor a build context specified: invalid compose project`. Running `docker compose -f .reward/reward-env.yml up -d` successfully starts the containers (`node` and `db`), but `reward info` incorrectly shows "Environment Status: Stopped" despite the containers running. This suggests issues with Reward’s handling of the `local` environment type and its state tracking.

### Steps to Reproduce
1. Initialize a new Reward environment in the project directory (`~/Sites/my-node-react`):
   ```bash
   reward env-init node-react
  1. Configure the project’s .env file (my-node-react-project/.env):
    REWARD_ENV_NAME=node-react
    REWARD_ENV_TYPE=local
    REWARD_WEB_ROOT=/app/frontend
    TRAEFIK_DOMAIN=node-react.test
    TRAEFIK_SUBDOMAIN=
    TRAEFIK_EXTRA_HOSTS=
    REWARD_DB=true
    REWARD_ELASTICSEARCH=false
    REWARD_OPENSEARCH=false
    REWARD_OPENSEARCH_DASHBOARDS=false
    REWARD_VARNISH=false
    REWARD_RABBITMQ=false
    REWARD_REDIS=false
    REWARD_MERCURE=false
    MARIADB_VERSION=10.6
    NODE_VERSION=20
    REWARD_SYNC_ENABLED=false
    REWARD_SYNC_IGNORE=
    REWARD_ALLURE=false
    REWARD_SELENIUM=false
    REWARD_SELENIUM_DEBUG=false
    REWARD_BLACKFIRE=false
    REWARD_SPLIT_SALES=false
    REWARD_SPLIT_CHECKOUT=false
    REWARD_TEST_DB=false
    REWARD_MAGEPACK=false
    BLACKFIRE_CLIENT_ID=
    BLACKFIRE_CLIENT_TOKEN=
    BLACKFIRE_SERVER_ID=
    BLACKFIRE_SERVER_TOKEN=
    XDEBUG_VERSION=
    REWARD_SHELL_CONTAINER=node
    REWARD_SHELL_COMMAND=bash
    REWARD_SHELL_USER=root
    REWARD_PHP_ENABLED=false
    
  2. Configure the project’s .reward/reward-env.yml file:
    services:
      node:
        image: node:${NODE_VERSION:-20}
        ports:
          - "3000:3000"
          - "3001:3001"
        volumes:
          - ../frontend:/app/frontend
          - ../backend:/app/backend
          - /app/node_modules
        working_dir: /app
        environment:
          - NODE_ENV=development
        labels:
          - traefik.http.routers.${REWARD_ENV_NAME}-node.rule=Host(`${TRAEFIK_DOMAIN}`)
          - traefik.http.services.${REWARD_ENV_NAME}-node.loadbalancer.server.port=3000
      db:
        image: mariadb:${MARIADB_VERSION:-10.6}
        ports:
          - "3306:3306"
        environment:
          - MYSQL_ROOT_PASSWORD=root
          - MYSQL_DATABASE=myapp
        volumes:
          - db_data:/var/lib/mysql
    volumes:
      db_data:
    
  3. Create global ~/.reward/.env to override PHP defaults:
    REWARD_SHELL_CONTAINER=node
    REWARD_SHELL_COMMAND=bash
    REWARD_SHELL_USER=root
    REWARD_PHP_ENABLED=false
    
  4. Run reward env up:
    • Error: service "php-fpm" has neither an image nor a build context specified: invalid compose project.
  5. Run docker compose -f .reward/reward-env.yml up -d:
    • Containers (node and db) start successfully, verifiable with docker ps.
  6. Run reward info:
    • Shows "Environment Status: Stopped" despite running containers.

Expected Behavior

  • reward env up should start the environment without including a php-fpm service, respecting REWARD_PHP_ENABLED=false and the project’s .reward/reward-env.yml which defines only node and db services.
  • reward info should show "Environment Status: Running" when containers are active, whether started via reward env up or docker compose.

Actual Behavior

  • reward env up fails with the error: service "php-fpm" has neither an image nor a build context specified: invalid compose project.
  • reward info incorrectly reports "Environment Status: Stopped" after starting containers with docker compose -f .reward/reward-env.yml up -d.

Environment

  • Reward Version: [reward version 0.7.3+202501091243]
  • Docker Version: [Docker version 28.0.4, build b8034c0]
  • Docker Compose Version: [Docker Compose version v2.34.0-desktop.1]
  • Operating System: [Windows 11 with ubuntu virtualization]
  • Global Configuration:
    # Contents of ~/.reward.yml
    log_level: info
    debug: false
    reward_shared_composer: true
    reward_traefik_bind_additional_http_ports: []
    reward_traefik_bind_additional_https_ports: []
    
    # Contents of ~/.reward/.env
    REWARD_SHELL_CONTAINER=node
    REWARD_SHELL_COMMAND=bash
    REWARD_SHELL_USER=root
    REWARD_PHP_ENABLED=false
    

Additional Information

  • The php-fpm service appears to be included by Reward’s default local template, despite setting REWARD_PHP_ENABLED=false in both project and global configurations.
  • Running docker compose -f .reward/reward-env.yml up -d bypasses the php-fpm error, confirming the project-specific configuration is correct.
  • Clearing the cache (rm -rf ~/.reward/cache) and reinitializing the environment (reward env-init node-react) did not resolve the issue.
  • The reward info command fails to detect running containers, suggesting a bug in Reward’s state tracking for non-PHP environments or when using docker compose directly.
  • The --force flag in reward env-init node-react --force was unsupported, as noted previously, requiring manual .env deletion to reinitialize.
  • The project is a Node.js + React.js + MySQL application (User Management App), not a PHP-based project like Magento or Shopware.

Suggested Fix

  • Ensure Reward respects REWARD_PHP_ENABLED=false and excludes php-fpm from the local environment template for non-PHP projects.
  • Fix reward info to accurately reflect container states when containers are started via docker compose or when bypassing Reward’s internal templates.
  • Consider documenting or supporting non-PHP environments (e.g., Node.js) more explicitly in the local environment type.

Workaround

  • Use docker compose -f .reward/reward-env.yml up -d to start the environment without errors.
  • Stop the environment with docker compose -f .reward/reward-env.yml down.
  • Alternatively, use a standard docker-compose.yml to avoid Reward entirely:
    services:
      node:
        image: node:20
        ports:
          - "3000:3000"
          - "3001:3001"
        volumes:
          - ./frontend:/app/frontend
          - ./backend:/app/backend
          - /app/node_modules
        working_dir: /app
        environment:
          - NODE_ENV=development
      db:
        image: mariadb:10.6
        ports:
          - "3306:3306"
        environment:
          - MYSQL_ROOT_PASSWORD=root
          - MYSQL_DATABASE=myapp
        volumes:
          - db_data:/var/lib/mysql
    volumes:
      db_data:
    

zaheerbadi avatar Jul 23 '25 14:07 zaheerbadi

This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Aug 07 '25 03:08 github-actions[bot]