Edit Dockerfile
This commit is contained in:
+122
-44
@@ -1,16 +1,28 @@
|
||||
# =========================================================
|
||||
# 1. APPLICATION STAGE (Single Stage untuk Lingkungan Offline)
|
||||
# APPLICATION STAGE
|
||||
# Laravel + PHP 7.4 + OCI8 + Nginx
|
||||
# =========================================================
|
||||
|
||||
FROM 10.15.39.186:8083/php74-fpm-oci8-lengkap:1.0
|
||||
FROM 10.15.39.186:8084/library/php:7.4-fpm
|
||||
|
||||
# =========================================================
|
||||
# Proxy
|
||||
# =========================================================
|
||||
|
||||
ARG http_proxy
|
||||
ARG https_proxy
|
||||
|
||||
ENV http_proxy=$http_proxy
|
||||
ENV https_proxy=$https_proxy
|
||||
ENV http_proxy=${http_proxy}
|
||||
ENV https_proxy=${https_proxy}
|
||||
ENV HTTP_PROXY=${http_proxy}
|
||||
ENV HTTPS_PROXY=${https_proxy}
|
||||
|
||||
# =========================================================
|
||||
# System dependencies
|
||||
# =========================================================
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
nginx \
|
||||
vim \
|
||||
wget \
|
||||
libpng-dev \
|
||||
@@ -21,51 +33,54 @@ RUN apt-get update && apt-get install -y \
|
||||
libaio-dev \
|
||||
zip \
|
||||
git \
|
||||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
||||
&& docker-php-ext-install gd pdo pdo_mysql zip
|
||||
unzip \
|
||||
&& docker-php-ext-configure gd \
|
||||
--with-freetype \
|
||||
--with-jpeg \
|
||||
&& docker-php-ext-install \
|
||||
gd \
|
||||
pdo \
|
||||
pdo_mysql \
|
||||
zip \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN pear config-set http_proxy "http://10.15.3.20:80" && export PHP_DTRACE=yes
|
||||
# =========================================================
|
||||
# PEAR Proxy
|
||||
# =========================================================
|
||||
|
||||
# Install Composer
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
RUN pear config-set http_proxy "http://10.15.3.20:80"
|
||||
|
||||
# =========================================================
|
||||
# Composer
|
||||
# =========================================================
|
||||
|
||||
COPY --from=composer:2.2 /usr/bin/composer /usr/bin/composer
|
||||
|
||||
WORKDIR /var/www
|
||||
|
||||
# PERBAIKAN: Gunakan skema copy offline dari aplikasi sukses,
|
||||
# tetapi tambahkan flag chown untuk mencegah error Permission Denied (Error 500) pada Pod
|
||||
# =========================================================
|
||||
# Composer dependency
|
||||
# Copy hanya composer files terlebih dahulu agar Docker cache
|
||||
# =========================================================
|
||||
|
||||
COPY composer.json composer.lock ./
|
||||
|
||||
RUN composer install \
|
||||
--no-dev \
|
||||
--prefer-dist \
|
||||
--no-interaction \
|
||||
--optimize-autoloader
|
||||
|
||||
# =========================================================
|
||||
# Application
|
||||
# =========================================================
|
||||
|
||||
COPY --chown=www-data:www-data . .
|
||||
|
||||
RUN composer install
|
||||
# =========================================================
|
||||
# Laravel directories & permission
|
||||
# =========================================================
|
||||
|
||||
# Hapus proxy dari environment runtime
|
||||
#ENV http_proxy=
|
||||
#ENV https_proxy=
|
||||
|
||||
# Setup Nginx Config
|
||||
RUN echo 'server { \
|
||||
listen 80; \
|
||||
index index.php index.html; \
|
||||
error_log /var/log/nginx/error.log; \
|
||||
access_log /var/log/nginx/access.log; \
|
||||
root /var/www/public; \
|
||||
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; \
|
||||
} \
|
||||
location / { \
|
||||
try_files $uri $uri/ /index.php?$query_string; \
|
||||
gzip_static on; \
|
||||
} \
|
||||
}' > /etc/nginx/sites-available/default
|
||||
|
||||
# 1. Buat folder storage LENGKAP (termasuk storage/logs)
|
||||
# 2. Buat file log default laravel.log
|
||||
# 3. Tetapkan izin akses www-data secara menyeluruh ke root aplikasi
|
||||
RUN mkdir -p \
|
||||
/var/www/storage/framework/sessions \
|
||||
/var/www/storage/framework/views \
|
||||
@@ -74,11 +89,74 @@ RUN mkdir -p \
|
||||
/var/www/bootstrap/cache \
|
||||
&& touch /var/www/storage/logs/laravel.log \
|
||||
&& chown -R www-data:www-data /var/www \
|
||||
&& chmod -R 775 /var/www/storage /var/www/bootstrap/cache
|
||||
&& chmod -R 775 /var/www/storage \
|
||||
&& chmod -R 775 /var/www/bootstrap/cache
|
||||
|
||||
# Bersihkan cache konfigurasi lama agar tidak menyebabkan error 500 saat pod dinyalakan
|
||||
RUN php /var/www/artisan config:clear || true
|
||||
# =========================================================
|
||||
# Laravel cache
|
||||
# =========================================================
|
||||
|
||||
RUN php artisan config:clear || true \
|
||||
&& php artisan cache:clear || true \
|
||||
&& php artisan view:clear || true
|
||||
|
||||
# =========================================================
|
||||
# Nginx configuration
|
||||
# =========================================================
|
||||
|
||||
RUN rm -f /etc/nginx/sites-enabled/default \
|
||||
&& rm -f /etc/nginx/sites-available/default
|
||||
|
||||
RUN printf '%s\n' \
|
||||
'server {' \
|
||||
' listen 80;' \
|
||||
' server_name _;' \
|
||||
'' \
|
||||
' root /var/www/public;' \
|
||||
' index index.php index.html;' \
|
||||
'' \
|
||||
' access_log /var/log/nginx/access.log;' \
|
||||
' error_log /var/log/nginx/error.log;' \
|
||||
'' \
|
||||
' location / {' \
|
||||
' try_files $uri $uri/ /index.php?$query_string;' \
|
||||
' }' \
|
||||
'' \
|
||||
' location ~ \.php$ {' \
|
||||
' try_files $uri =404;' \
|
||||
' include fastcgi_params;' \
|
||||
' fastcgi_pass 127.0.0.1:9000;' \
|
||||
' fastcgi_index index.php;' \
|
||||
' fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' \
|
||||
' fastcgi_param PATH_INFO $fastcgi_path_info;' \
|
||||
' }' \
|
||||
'' \
|
||||
' location ~ /\.ht {' \
|
||||
' deny all;' \
|
||||
' }' \
|
||||
'}' \
|
||||
> /etc/nginx/sites-available/default
|
||||
|
||||
RUN ln -sf /etc/nginx/sites-available/default \
|
||||
/etc/nginx/sites-enabled/default
|
||||
|
||||
# =========================================================
|
||||
# Remove proxy from runtime
|
||||
# =========================================================
|
||||
|
||||
ENV http_proxy=""
|
||||
ENV https_proxy=""
|
||||
ENV HTTP_PROXY=""
|
||||
ENV HTTPS_PROXY=""
|
||||
|
||||
# =========================================================
|
||||
# Port
|
||||
# =========================================================
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
# =========================================================
|
||||
# Start PHP-FPM + Nginx
|
||||
# =========================================================
|
||||
|
||||
CMD ["sh", "-c", "php-fpm -D && exec nginx -g 'daemon off;'"]
|
||||
|
||||
Reference in New Issue
Block a user