Last active
August 26, 2024 06:43
-
-
Save mathieutu/88a3dd0b4a92065d3d093c93ac435bf0 to your computer and use it in GitHub Desktop.
Laravel Production Dockerfile using frankenphp.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# syntax=docker/dockerfile:1.4 | |
FROM node:21-alpine AS front | |
WORKDIR /usr/src/app | |
COPY --link package.json yarn.lock .yarnrc.yml ./ | |
COPY --link .yarn .yarn | |
RUN yarn install | |
COPY --link tailwind.config.ts postcss.config.cjs vite.config.ts tsconfig.json tsconfig.node.json ./ | |
COPY --link resources resources | |
RUN yarn build | |
FROM dunglas/frankenphp as back | |
WORKDIR /app | |
COPY --chmod=755 docker/entrypoint.sh /usr/local/bin/docker-entrypoint | |
ENTRYPOINT ["docker-entrypoint"] | |
CMD ["--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"] | |
# Image config | |
RUN install-php-extensions @composer zip pgsql pdo_pgsql | |
ENV SERVER_NAME=:80 | |
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" | |
# Laravel config | |
ENV APP_ENV production | |
ENV APP_DEBUG false | |
ENV LOG_CHANNEL stderr | |
# Allow composer to run as root | |
ENV COMPOSER_ALLOW_SUPERUSER 1 | |
# Install PHP dependencies | |
COPY --link composer.json composer.lock ./ | |
RUN composer install --no-dev --no-interaction --no-progress --no-autoloader --no-scripts | |
# Copy all application code into the Docker container | |
COPY --link docker/ . | |
COPY --link . . | |
COPY --link --from=front /usr/src/app/public/build ./public/build | |
RUN composer dump-autoload --optimize |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
php artisan route:cache | |
php artisan view:cache | |
php artisan config:cache | |
php artisan migrate --force | |
php artisan telescope:prune --hours=48 | |
exec docker-php-entrypoint "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment