{"id":23443246,"url":"https://github.com/istifano/php-docker-stack-demo","last_synced_at":"2026-05-03T01:38:32.367Z","repository":{"id":266911717,"uuid":"898936479","full_name":"ISTIFANO/PHP-DOCKER-STACK-DEMO","owner":"ISTIFANO","description":"PHP-DOCKER-STACK-DEMO","archived":false,"fork":false,"pushed_at":"2024-12-09T20:18:04.000Z","size":9887,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-09T04:43:26.542Z","etag":null,"topics":["docker","docker-compose","docker-image","dockerfile"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ISTIFANO.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-05T10:14:12.000Z","updated_at":"2024-12-09T20:18:08.000Z","dependencies_parsed_at":"2025-04-09T22:38:15.105Z","dependency_job_id":null,"html_url":"https://github.com/ISTIFANO/PHP-DOCKER-STACK-DEMO","commit_stats":null,"previous_names":["istifano/php-docker-stack-demo"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ISTIFANO/PHP-DOCKER-STACK-DEMO","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ISTIFANO%2FPHP-DOCKER-STACK-DEMO","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ISTIFANO%2FPHP-DOCKER-STACK-DEMO/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ISTIFANO%2FPHP-DOCKER-STACK-DEMO/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ISTIFANO%2FPHP-DOCKER-STACK-DEMO/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ISTIFANO","download_url":"https://codeload.github.com/ISTIFANO/PHP-DOCKER-STACK-DEMO/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ISTIFANO%2FPHP-DOCKER-STACK-DEMO/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32555839,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T00:31:16.350Z","status":"ssl_error","status_checked_at":"2026-05-03T00:31:15.546Z","response_time":132,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","docker-image","dockerfile"],"created_at":"2024-12-23T18:17:01.116Z","updated_at":"2026-05-03T01:38:32.352Z","avatar_url":"https://github.com/ISTIFANO.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP-DOCKER-STACK-DEMO\n# Dockerizing PHP Applications Guide\n\n## Table of Contents\n- [Prerequisites](#prerequisites)\n- [Project Structure](#project-structure)\n- [Docker Configuration](#docker-configuration)\n- [Step-by-Step Setup](#step-by-step-setup)\n- [Development Environment](#development-environment)\n- [Production Considerations](#production-considerations)\n- [Troubleshooting](#troubleshooting)\n\n## Prerequisites\n\nBefore you begin, ensure you have the following installed:\n- Docker Engine (version 20.10 or later)\n- Docker Compose (version 2.0 or later)\n- Git (optional, but recommended for version control)\n\n## Project Structure\n\nYour project should follow this basic structure:\n```\nyour-php-app/\n├── src/                     # PHP application source code\n├── docker/                  # Docker-related files\n│   ├── php/                # PHP configuration\n│   │   └── Dockerfile      # PHP container configuration\n│   └── nginx/              # Nginx configuration (if using)\n│       └── default.conf    # Nginx server configuration\n├── docker-compose.yml      # Service orchestration\n├── .dockerignore          # Files to exclude from builds\n└── README.md              # This documentation\n```\n\n## Docker Configuration\n\n### PHP Dockerfile\n\nCreate `docker/php/Dockerfile`:\n\n```dockerfile\nFROM php:8.2-fpm\n\n# Install system dependencies\nRUN apt-get update \u0026\u0026 apt-get install -y \\\n    git \\\n    curl \\\n    libpng-dev \\\n    libonig-dev \\\n    libxml2-dev \\\n    zip \\\n    unzip\n\n# Clear cache\nRUN apt-get clean \u0026\u0026 rm -rf /var/lib/apt/lists/*\n\n# Install PHP extensions\nRUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd\n\n# Install Composer\nCOPY --from=composer:latest /usr/bin/composer /usr/bin/composer\n\n# Set working directory\nWORKDIR /var/www\n\n# Copy application files\nCOPY . /var/www\n\n# Set permissions\nRUN chown -R www-data:www-data /var/www\n\n# Switch to non-root user\nUSER www-data\n```\n\n### Docker Compose Configuration\n\nCreate `docker-compose.yml`:\n\n```yaml\nversion: '3.8'\n\nservices:\n  app:\n    build:\n      context: .\n      dockerfile: docker/php/Dockerfile\n    container_name: php-app\n    restart: unless-stopped\n    working_dir: /var/www\n    volumes:\n      - ./:/var/www\n    networks:\n      - app-network\n\n  nginx:\n    image: nginx:alpine\n    container_name: php-nginx\n    restart: unless-stopped\n    ports:\n      - \"8000:80\"\n    volumes:\n      - ./:/var/www\n      - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf\n    networks:\n      - app-network\n\n  db:\n    image: mysql:8.0\n    container_name: php-db\n    restart: unless-stopped\n    environment:\n      MYSQL_DATABASE: ${DB_DATABASE}\n      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}\n      MYSQL_PASSWORD: ${DB_PASSWORD}\n      MYSQL_USER: ${DB_USERNAME}\n    volumes:\n      - dbdata:/var/lib/mysql\n    networks:\n      - app-network\n\nnetworks:\n  app-network:\n    driver: bridge\n\nvolumes:\n  dbdata:\n    driver: local\n```\n\n## Step-by-Step Setup\n\n1. **Initialize Your Project**\n   ```bash\n   mkdir your-php-app\n   cd your-php-app\n   ```\n\n2. **Create Docker Configuration Files**\n   - Create the directory structure shown above\n   - Copy the Dockerfile and docker-compose.yml content\n   - Create a `.dockerignore` file:\n     ```\n     .git\n     .gitignore\n     .env\n     vendor/\n     node_modules/\n     ```\n\n3. **Configure Environment Variables**\n   ```bash\n   cp .env.example .env\n   ```\n   Update the `.env` file with your database credentials and other configurations.\n\n4. **Build and Start Containers**\n   ```bash\n   docker-compose up -d --build\n   ```\n\n5. **Install Dependencies**\n   ```bash\n   docker-compose exec app composer install\n   ```\n\n6. **Set Permissions**\n   ```bash\n   docker-compose exec app chmod -R 775 storage bootstrap/cache\n   ```\n\n## Development Environment\n\n### Accessing Containers\n\n- PHP container: `docker-compose exec app bash`\n- MySQL container: `docker-compose exec db mysql -u root -p`\n- Logs: `docker-compose logs -f [service_name]`\n\n### Common Commands\n\n```bash\n# Start containers\ndocker-compose up -d\n\n# Stop containers\ndocker-compose down\n\n# Rebuild containers\ndocker-compose up -d --build\n\n# View logs\ndocker-compose logs -f\n\n# Run composer commands\ndocker-compose exec app composer install\n```\n\n## Production Considerations\n\n1. **Security**\n   - Remove development tools and dependencies\n   - Use production-optimized PHP configuration\n   - Implement proper access controls\n   - Use secure networking configurations\n\n2. **Performance**\n   - Enable PHP OPcache\n   - Configure appropriate PHP-FPM settings\n   - Implement caching strategies\n   - Use production-ready web server configurations\n\n3. **Monitoring**\n   - Implement health checks\n   - Set up logging and monitoring\n   - Configure backup strategies\n\n## Troubleshooting\n\n### Common Issues and Solutions\n\n1. **Permission Issues**\n   ```bash\n   # Fix storage permissions\n   docker-compose exec app chown -R www-data:www-data storage\n   chmod -R 775 storage\n   ```\n\n2. **Container Won't Start**\n   - Check logs: `docker-compose logs [service_name]`\n   - Verify port availability\n   - Ensure all required environment variables are set\n\n3. **Database Connection Issues**\n   - Verify database credentials in `.env`\n   - Ensure database service is running\n   - Check network connectivity between containers\n\n### Getting Help\n\nIf you encounter issues:\n1. Check the Docker and container logs\n2. Review the configurations for syntax errors\n3. Verify environment variables are properly set\n4. Consult the official Docker and PHP documentation\n5. Search for similar issues in the community forums\n\n## Additional Resources\n\n- [Official Docker Documentation](https://docs.docker.com/)\n- [PHP Official Docker Images](https://hub.docker.com/_/php)\n- [Nginx Documentation](https://nginx.org/en/docs/)\n- [Docker Compose Documentation](https://docs.docker.com/compose/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fistifano%2Fphp-docker-stack-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fistifano%2Fphp-docker-stack-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fistifano%2Fphp-docker-stack-demo/lists"}