Add Dockerfile for Laravel application setup
- Introduced a new Dockerfile utilizing PHP 8.2 for the Laravel application. - Configured timezone settings and installed necessary dependencies including Git, cURL, and PHP extensions. - Set up cron jobs for Laravel task scheduling and included Composer for dependency management. - Implemented file permission settings to enhance security and functionality across application directories. - Added commands for Laravel application initialization, including migration, key generation, and caching operations. - Included a custom entrypoint script to streamline container startup processes. These changes establish a robust Docker environment for the Laravel application, improving deployment and operational efficiency.
This commit is contained in:
-80
@@ -1,80 +0,0 @@
|
||||
# Laravel için PHP 8.2 resmi imajını kullanıyoruz
|
||||
FROM php:8.2-fpm
|
||||
|
||||
ENV TZ=Europe/Istanbul
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
|
||||
# Çalışma dizinini belirleyelim
|
||||
WORKDIR /var/www
|
||||
|
||||
# Gerekli bağımlılıkları yükleyelim
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
unzip \
|
||||
curl \
|
||||
libpng-dev \
|
||||
libonig-dev \
|
||||
libxml2-dev \
|
||||
zip \
|
||||
cron \
|
||||
&& docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd \
|
||||
&& echo "* * * * * cd /var/www && php artisan schedule:run >> /dev/null 2>&1" >> /etc/cron.d/laravel-cron \
|
||||
&& chmod 0644 /etc/cron.d/laravel-cron \
|
||||
&& crontab /etc/cron.d/laravel-cron \
|
||||
&& service cron start
|
||||
|
||||
# Composer'ı yükleyelim
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
# Laravel proje dosyalarını kopyalayalım
|
||||
COPY . .
|
||||
|
||||
# Gerekli dizinleri oluşturma
|
||||
RUN mkdir -p /var/www/storage/app/private/scribe
|
||||
|
||||
# Start of Selection
|
||||
RUN set -x && \
|
||||
echo "Dosya izinleri ayarlanıyor..." && \
|
||||
chown -R www-data:www-data /var/www && \
|
||||
echo "chown komutu tamamlandı" && \
|
||||
find /var/www -type d -exec chmod 775 {} \; && \
|
||||
echo "Dizin izinleri ayarlandı" && \
|
||||
find /var/www -type f -exec chmod 664 {} \; && \
|
||||
echo "Dosya izinleri ayarlandı" && \
|
||||
chmod -R 775 /var/www/storage && \
|
||||
echo "Storage izinleri ayarlandı" && \
|
||||
chmod -R 775 /var/www/bootstrap/cache && \
|
||||
echo "Cache izinleri ayarlandı" && \
|
||||
chmod -R 775 /var/www/storage/framework/views && \
|
||||
echo "Views izinleri ayarlandı" && \
|
||||
chmod -R 775 /var/www/public && \
|
||||
echo "Public dizin izinleri ayarlandı"
|
||||
|
||||
# Laravel uygulamasını başlatma ve loglama
|
||||
RUN set -x && \
|
||||
echo "Laravel kurulum komutları başlatılıyor..." && \
|
||||
php artisan migrate && \
|
||||
echo "Migrasyon tamamlandı" && \
|
||||
php artisan key:generate && \
|
||||
echo "Uygulama anahtarı oluşturuldu" && \
|
||||
php artisan config:cache && \
|
||||
echo "Konfigürasyon önbelleğe alındı" && \
|
||||
php artisan route:cache && \
|
||||
echo "Rotalar önbelleğe alındı" && \
|
||||
php artisan view:cache && \
|
||||
echo "Görünümler önbelleğe alındı" && \
|
||||
php artisan storage:link && \
|
||||
echo "Storage sembolik bağlantısı oluşturuldu" && \
|
||||
php artisan scribe:generate && \
|
||||
echo "API dokümantasyonu oluşturuldu" && \
|
||||
echo "Laravel uygulaması başarıyla başlatıldı."
|
||||
|
||||
|
||||
# Apache veya Nginx kullanılacaksa, burada ayarları yapabiliriz (Opsiyonel)
|
||||
|
||||
# Container başlangıcında çalışacak script
|
||||
COPY docker-entrypoint.sh /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||
Reference in New Issue
Block a user