Files
php-auth/Dockerfile
Ron Rise 25c44bf595
All checks were successful
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 1m5s
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 1m2s
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 1m10s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Successful in 1m2s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 1m9s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 35s
🏗️✨ Build Workflow / 🖥️ 🔨 Build (push) Successful in 20m41s
🏗️✨ Build Workflow / 🖥️ 🔨 Build Migrations (push) Successful in 1m3s
Add multi-stage build for front-end assets in Dockerfile
2026-01-02 16:20:29 -05:00

77 lines
2.5 KiB
Docker

# Use the RoadRunner image as a base for the first stage
FROM ghcr.io/roadrunner-server/roadrunner:2025.1.6 AS roadrunner
# Use the official Composer image as the base for the library stage
FROM siteworxpro/composer AS library
# Add Composer configuration files to the working directory
ADD composer.json composer.lock ./
# Install PHP dependencies, ignoring platform requirements and excluding development dependencies
RUN composer install --optimize-autoloader --ignore-platform-reqs --no-dev
FROM node:22-alpine AS node
# Set the working directory to /app
WORKDIR /app/front-end
# Copy package.json and package-lock.json to the working directory
COPY front-end/ .
# Install Node.js dependencies
RUN npm install && npm run build
# Use the official PHP CLI image with Alpine Linux for the second stage
FROM siteworxpro/php:8.5.1-cli-alpine AS php
ARG KAFKA_ENABLED=0
ARG USER=appuser
ARG UID=1000
# Move the production PHP configuration file to the default location
RUN mv /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini \
&& apk add libpq-dev linux-headers --no-cache \
&& docker-php-ext-install pdo_pgsql sockets pcntl \
&& rm -rf /var/cache/apk/*
RUN if [ "$KAFKA_ENABLED" -eq 1 ] ; then \
echo "Kafka support enabled" ; \
apk add autoconf g++ librdkafka-dev make --no-cache ; \
pecl install rdkafka && docker-php-ext-enable rdkafka ; \
apk del autoconf g++ make ; \
else \
echo "Kafka support disabled" ; \
exit 0 ; \
fi
# Set the working directory to /app
WORKDIR /app
# Copy the RoadRunner binary from the first stage to the second stage
COPY --from=roadrunner /usr/bin/rr /usr/local/bin/rr
# Copy the installed PHP dependencies from the library stage
COPY --from=library /app/vendor /app/vendor
# Copy the built front-end assets from the node stage
COPY --from=node /app/public /app/public
# Copy the RoadRunner configuration file and source
ADD src src/
ADD generated generated/
ADD protos protos/
ADD server.php cli.php grpc-worker.php .rr.yaml config.php ./
EXPOSE 9501 9001
# Create a non-root user and set ownership of the /app directory
RUN if [ ! $UID -eq 0 ] ; then addgroup -g $UID $USER && adduser -D -u $UID -G $USER $USER && chown -R $USER:$USER /app ; fi
USER $USER
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s \
CMD curl -f http://localhost:9501/healthz || exit 1
# Entrypoint command to run the RoadRunner server with the specified configuration
ENTRYPOINT ["rr", "serve"]
CMD ["-c", ".rr.yaml", "-s"]