From 1a0f95d82bc922fed37cac1c693de6a99cca9153 Mon Sep 17 00:00:00 2001 From: LailaWulandarii Date: Fri, 2 Jan 2026 08:07:42 +0700 Subject: [PATCH] initiate docker and ngix for render hosting --- DockerFile | 47 +++++++++++++++++++++++++++++++++++++++++++++++ nginx.conf | 29 +++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 DockerFile create mode 100644 nginx.conf diff --git a/DockerFile b/DockerFile new file mode 100644 index 0000000..3d5e217 --- /dev/null +++ b/DockerFile @@ -0,0 +1,47 @@ +# Menggunakan image PHP 8.2 FPM resmi +FROM php:8.2-fpm + +# Mengatur working directory +WORKDIR /var/www + +# Menginstal dependensi sistem dan ekstensi PHP yang dibutuhkan Laravel +RUN apt-get update && apt-get install -y \ + build-essential \ + libpng-dev \ + libjpeg62-turbo-dev \ + libfreetype6-dev \ + locales \ + zip \ + jpegoptim optipng pngquant gifsicle \ + vim \ + unzip \ + git \ + curl \ + libzip-dev \ + nginx + +# Membersihkan cache +RUN apt-get clean && rm -rf /var/lib/apt/lists/* + +# Menginstal ekstensi PHP +RUN docker-php-ext-install pdo_mysql zip exif pcntl +RUN docker-php-ext-configure gd --with-freetype --with-jpeg +RUN docker-php-ext-install gd + +# Menginstal Composer secara langsung dari image resmi +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + +# Menyalin seluruh kode proyek ke dalam kontainer +COPY . /var/www + +# Memberikan izin akses (permissions) ke folder storage dan cache +RUN chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache + +# Menyalin konfigurasi Nginx (akan kita buat di langkah berikutnya) +COPY nginx.conf /etc/nginx/nginx.conf + +# Mengekspos port 80 +EXPOSE 80 + +# Menjalankan script PHP-FPM dan Nginx secara bersamaan +CMD service nginx start && php-fpm diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..0c76176 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,29 @@ +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + server { + listen 80; + index index.php index.html; + server_name localhost; + root /var/www/public; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location ~ \.php$ { + try_files $uri =404; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass 127.0.0.1:9000; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + } + } +}