36 lines
1.0 KiB
Docker
36 lines
1.0 KiB
Docker
# Base image: Hyperf with PHP 8.3, Alpine, Swoole
|
|
FROM hyperf/hyperf:8.3-alpine-v3.19-swoole-v6
|
|
|
|
USER root
|
|
|
|
# Install Node.js (for Vite frontend build), PostgreSQL client, and PHP extensions
|
|
RUN apk add --no-cache \
|
|
nodejs \
|
|
npm \
|
|
postgresql-dev \
|
|
php83-pdo_pgsql \
|
|
php83-pgsql
|
|
|
|
# Enable extensions (only needed if they don't auto-enable)
|
|
RUN echo "extension=pdo_pgsql.so" > /etc/php83/conf.d/01_pdo_pgsql.ini && \
|
|
echo "extension=pgsql.so" > /etc/php83/conf.d/00_pgsql.ini
|
|
|
|
# Copy application code
|
|
WORKDIR /var/app
|
|
COPY . /var/app
|
|
|
|
# Install Composer dependencies
|
|
RUN composer install --no-dev --optimize-autoloader
|
|
|
|
# Install Node dependencies and build frontend assets
|
|
RUN npm ci --prefer-offline && npm run build && rm -rf node_modules
|
|
|
|
# Expose Swoole HTTP port
|
|
EXPOSE 9501
|
|
|
|
# Healthcheck endpoint (optional but works with Compose)
|
|
HEALTHCHECK --interval=15s --timeout=5s --start-period=10s CMD curl -f http://localhost:9501/health || exit 1
|
|
|
|
# Run Hyperf Swoole server
|
|
CMD ["php", "artisan", "start"]
|