Skip to content

Instantly share code, notes, and snippets.

@fhferreira
Forked from Victor-Fiamoncini/Dockerfile
Created October 7, 2024 10:42
Show Gist options
  • Save fhferreira/fa8e9339bf5bc9e98dcc76c42fb62266 to your computer and use it in GitHub Desktop.
Save fhferreira/fa8e9339bf5bc9e98dcc76c42fb62266 to your computer and use it in GitHub Desktop.
Franken PHP Dockerfile
# Base image with PHP and FrankenPHP
FROM dunglas/frankenphp:1-php8.3 AS frankenphp
RUN apt-get update && apt-get install -y zip libzip-dev libpq-dev libicu-dev wget acl curl
RUN docker-php-ext-install sockets zip
RUN docker-php-ext-configure zip
RUN docker-php-ext-install pgsql pdo_pgsql intl
ENV SERVER_NAME my_app
ENV FRANKENPHP_CONFIG "worker ./public/index.php"
ENV APP_RUNTIME Runtime\\FrankenPhpSymfony\\Runtime
# Set working directory
WORKDIR /my_app/app
COPY --from=composer:2.2 /usr/bin/composer /usr/bin/composer
# Copy composer files and install dependencies
COPY composer.json composer.lock ./
RUN composer install --no-scripts --no-interaction --no-autoloader --no-ansi
RUN composer dump-autoload --optimize --no-ansi && composer clear-cache --no-ansi
# Copy Symfony app files
COPY . .
# Define the build argument (DATABASE_URL) to build Symfony cache
ARG DATABASE_URL
ENV DATABASE_URL=${DATABASE_URL}
RUN php bin/console cache:warmup
# Copy Caddyfile for configuration
COPY ./Caddyfile /etc/caddy/Caddyfile
# Expose port 80
EXPOSE 80
# Run FrankenPHP with Caddy configuration
CMD frankenphp run --config /etc/caddy/Caddyfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment