Last active
July 15, 2025 08:48
-
-
Save afandiyusuf/2e6d1617212a19a31806de9810b6c37f to your computer and use it in GitHub Desktop.
Dockerfile for laravel
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
# Use the official PHP image with PHP 8.1 and Nginx | |
FROM php:8.1-fpm AS php-nginx | |
# Install necessary extensions and packages | |
RUN apt-get update && apt-get install -y \ | |
nginx \ | |
libonig-dev \ | |
libxml2-dev \ | |
zip \ | |
unzip \ | |
git \ | |
curl \ | |
libzip-dev \ | |
libpq-dev \ | |
&& docker-php-ext-install \ | |
pdo_mysql \ | |
mbstring \ | |
exif \ | |
pcntl \ | |
bcmath \ | |
opcache \ | |
zip \ | |
xml \ | |
&& pecl install xdebug \ | |
&& docker-php-ext-enable xdebug \ | |
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer | |
# Create the storage directory and set ownership and permissions | |
RUN mkdir -p /var/www/html/storage \ | |
&& chown -R www-data:www-data /var/www/html/storage \ | |
&& chmod -R 777 /var/www/html/storage | |
# Copy Nginx configuration | |
COPY ./nginx/default.conf /etc/nginx/sites-available/default | |
# Set working directory | |
WORKDIR /var/www/html | |
# Copy application files | |
COPY . . | |
RUN chmod -R 777 /var/www/html/storage | |
RUN composer clear-cache | |
RUN composer install --no-scripts | |
RUN composer dump-autoload --optimize | |
# Generate Laravel application key | |
RUN php artisan key:generate | |
RUN php artisan storage:link | |
# Run orchid installation | |
RUN php artisan orchid:install | |
# Expose ports | |
EXPOSE 8080 | |
# Start Nginx and PHP-FPM | |
CMD service nginx start && php-fpm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment