Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@
# PHP API Stack — Environment Configuration
# Image: kariricode/php-api-stack
# ============================================
# Demo Mode (optional)
# Set to 'true' to install demo landing page when no application exists
DEMO_MODE=true
# Mode debug (optional) 0=inactive 1=acrive
ENABLE_XDEBUG=1
# Health Check Installation (optional)
# Set to 'true' to install health check endpoint
# Automatically enabled when DEMO_MODE=true
HEALTH_CHECK_INSTALL=true
# ============================================
# Application
# ============================================
APP_NAME=php-api-stack
Expand Down Expand Up @@ -110,7 +100,7 @@ PHP_FPM_REQUEST_SLOWLOG_TIMEOUT=30s
PHP_OPCACHE_ENABLE=1
PHP_OPCACHE_MEMORY=256
PHP_OPCACHE_MAX_FILES=20000
PHP_OPCACHE_VALIDATE_TIMESTAMPS=0
PHP_OPCACHE_VALIDATE_TIMESTAMPS=1
PHP_OPCACHE_REVALIDATE_FREQ=0
PHP_OPCACHE_JIT=tracing
PHP_OPCACHE_JIT_BUFFER_SIZE=128M
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
./app/public/health.php
./app/public/index.php

# Public directory (application-specific files)
/public/

# Logs
./logs/
*.log
Expand Down
14 changes: 0 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -425,20 +425,6 @@ COPY scripts/quick-start.sh /usr/local/bin/quick-start

RUN chmod +x /usr/local/bin/docker-entrypoint /usr/local/bin/process-configs /usr/local/bin/quick-start

# ----------------------------------------------------------------------------
# Healthcheck templates (staged, published at runtime)
# ----------------------------------------------------------------------------
RUN install -d -m 0755 /opt/php-api-stack-templates

COPY --chown=nginx:nginx php/index.php /opt/php-api-stack-templates/index.php
COPY --chown=nginx:nginx php/health.php /opt/php-api-stack-templates/health.php

# Validate syntax at build time
RUN set -eux; \
php -l /opt/php-api-stack-templates/index.php; \
php -l /opt/php-api-stack-templates/health.php; \
echo "✓ Healthcheck templates validated successfully"

WORKDIR /var/www/html

# ============================================================================
Expand Down
19 changes: 7 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,8 @@ ALPINE_VERSION?=3.21
COMPOSER_VERSION?=2.8.12
SYMFONY_CLI_VERSION?=5.15.1

DEMO_MODE ?= false
HEALTH_CHECK_INSTALL ?= false

# Common build args block
BUILD_ARGS := \
--build-arg DEMO_MODE=$(DEMO_MODE) \
--build-arg HEALTH_CHECK_INSTALL=$(HEALTH_CHECK_INSTALL) \
--build-arg VERSION=$(VERSION) \
--build-arg PHP_VERSION=$(PHP_VERSION) \
--build-arg PHP_CORE_EXTENSIONS=$(PHP_CORE_EXTENSIONS) \
Expand All @@ -85,9 +80,7 @@ PROD_BUILD_ARGS := \
--build-arg PHP_OPCACHE_ENABLE=1 \
--build-arg PHP_OPCACHE_MEMORY_CONSUMPTION=256 \
--build-arg XDEBUG_ENABLE=0 \
--build-arg APP_DEBUG=false \
--build-arg DEMO_MODE=false \
--build-arg HEALTH_CHECK_INSTALL=false
--build-arg APP_DEBUG=false


# Development build args
Expand All @@ -98,10 +91,8 @@ XDEBUG_VERSION ?= 3.4.6
DEV_BUILD_ARGS := \
--build-arg APP_ENV=development \
--build-arg APP_DEBUG=true \
--build-arg DEMO_MODE=true \
--build-arg SYMFONY_CLI_VERSION=$(SYMFONY_CLI_VERSION) \
--build-arg XDEBUG_VERSION=$(XDEBUG_VERSION) \
--build-arg HEALTH_CHECK_INSTALL=true \
--build-arg XDEBUG_ENABLE=$(XDEBUG_ENABLE)

.PHONY: help
Expand Down Expand Up @@ -186,11 +177,10 @@ build-base: ## Build base image (target=base) - for debugging only

.PHONY: build-test
build-test: ## Build test image (production with health check)
@echo "$(GREEN)Building test image with comprehensive health check...$(NC)"
@echo "$(GREEN)Building test image...$(NC)"
@docker build \
$(BUILD_ARGS) \
$(PROD_BUILD_ARGS) \
--build-arg HEALTH_CHECK_INSTALL=true \
--target production \
-t $(FULL_IMAGE):test \
.
Expand Down Expand Up @@ -229,23 +219,28 @@ run-dev: ## Run dev container with Xdebug
@echo "$(GREEN)Starting dev container...$(NC)"
@docker stop $(DEV_CONTAINER) >/dev/null 2>&1 || true
@docker rm $(DEV_CONTAINER) >/dev/null 2>&1 || true

@if docker ps --format '{{.Ports}}' | grep -q '$(DEV_PORT)->'; then \
echo "$(RED)X Port $(DEV_PORT) is already in use!$(NC)"; \
echo "$(YELLOW)Try another port:$(NC) make run-dev DEV_PORT=9000"; \
exit 1; \
fi

@docker run -d \
--name $(DEV_CONTAINER) \
-p $(DEV_PORT):80 \
-p 9003:9003 \
--env-file $(ENV_FILE) \
-e APP_ENV=development \
-e XDEBUG_ENABLE=1 \
-v $(PWD):/var/www/html \
-v $(PWD)/logs:/var/log \
$(FULL_IMAGE):$(IMAGE_TAG)

@echo "$(GREEN)OK: Dev container running at http://localhost:$(DEV_PORT)$(NC)"
@echo "$(CYAN)Xdebug enabled on port 9003$(NC)"


.PHONY: run-test
run-test: build-test ## Run test container
@echo "$(GREEN)Starting test container...$(NC)"
Expand Down
3 changes: 0 additions & 3 deletions docker-compose.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ services:
image: kariricode/php-api-stack:latest
container_name: php-api-stack
restart: unless-stopped
environment:
- DEMO_MODE=true
- HEALTH_CHECK_INSTALL=true
env_file:
- .env
ports:
Expand Down
24 changes: 0 additions & 24 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -180,30 +180,6 @@ if [ -f "/var/www/html/bin/console" ]; then
fi
fi

# ----------------------------------------------------------------------------
# DEMO_MODE
# ----------------------------------------------------------------------------
if [ "${DEMO_MODE}" = "true" ] && [ -f "/opt/php-api-stack-templates/index.php" ]; then
log_info "Publishing demo index.php to /var/www/html/public"
mkdir -p /var/www/html/public
cp /opt/php-api-stack-templates/index.php /var/www/html/public/index.php
chown nginx:nginx /var/www/html/public/index.php
chmod 644 /var/www/html/public/index.php
else
rm -f /var/www/html/public/index.php 2>/dev/null || true
fi

# HEALTH_CHECK_INSTALL
if [ "${HEALTH_CHECK_INSTALL}" = "true" ] && [ -f "/opt/php-api-stack-templates/health.php" ]; then
log_info "Publishing health.php to /var/www/html/public"
mkdir -p /var/www/html/public
cp /opt/php-api-stack-templates/health.php /var/www/html/public/health.php
chown nginx:nginx /var/www/html/public/health.php
chmod 644 /var/www/html/public/health.php
else
rm -f /var/www/html/public/health.php 2>/dev/null || true
fi

# -----------------------------------------------------------------------------
# XDEBUG
# -----------------------------------------------------------------------------
Expand Down
Loading
Loading