99 lines
3.2 KiB
Docker
99 lines
3.2 KiB
Docker
# =========================================================
|
|
# 1. COMPOSER STAGE (Untuk binary & vendor generation)
|
|
# =========================================================
|
|
FROM 10.15.39.186:8084/library/composer:2.7 AS composer
|
|
|
|
WORKDIR /app
|
|
|
|
# Salin file dependensi terlebih dahulu
|
|
COPY composer.json composer.lock ./
|
|
|
|
# PERBAIKAN 1: Menghapus opsi ilegal '--no-autoloader' (Penyebab utama Buildah crash status 1)
|
|
# Menambahkan '--no-interaction' agar aman berjalan otomatis di dalam GitLab CI
|
|
RUN composer install \
|
|
--no-interaction \
|
|
--no-plugins \
|
|
--no-scripts \
|
|
--no-dev \
|
|
--prefer-dist \
|
|
--ignore-platform-reqs
|
|
|
|
# Salin sisa kode aplikasi ke stage composer
|
|
COPY . .
|
|
|
|
# PERBAIKAN 2: Menghapus opsi '--no-plugins' dan '--no-scripts' dari dump-autoload
|
|
# Opsi tersebut tidak didukung oleh perintah dump-autoload pada Composer 2.x
|
|
RUN composer dump-autoload --optimize --no-dev
|
|
|
|
# =========================================================
|
|
# 2. APPLICATION STAGE
|
|
# =========================================================
|
|
FROM 10.15.39.186:8083/php74-fpm-oci8-lengkap:1.0
|
|
|
|
ARG http_proxy
|
|
ARG https_proxy
|
|
|
|
ENV http_proxy=$http_proxy
|
|
ENV https_proxy=$https_proxy
|
|
|
|
# Install Nginx & Dependencies
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
nginx \
|
|
unzip \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /var/www
|
|
|
|
# PERBAIKAN 3: Menambahkan '--chown=www-data:www-data' saat menyalin dari stage composer
|
|
# Ini wajib dilakukan agar folder aplikasi tidak terkunci sebagai milik 'root' (Pencegah Error 500)
|
|
COPY --from=composer --chown=www-data:www-data /app /var/www
|
|
|
|
# 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
|
|
|
|
# Setup direktori storage & bootstrap cache Laravel serta atur izin akses
|
|
# Menambahkan pembuatan folder 'storage/logs' dan file 'laravel.log' agar writeable
|
|
RUN mkdir -p \
|
|
/var/www/storage/framework/sessions \
|
|
/var/www/storage/framework/views \
|
|
/var/www/storage/framework/cache \
|
|
/var/www/storage/logs \
|
|
/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
|
|
|
|
# Bersihkan sisa cache bawaan dari repo lokal agar tidak bentrok di Pod produksi
|
|
RUN php /var/www/artisan config:clear || true
|
|
|
|
ENV APP_ENV=production
|
|
ENV APP_DEBUG=false
|
|
ENV DB_CONNECTION=dejos
|
|
|
|
EXPOSE 80
|
|
|
|
CMD ["sh", "-c", "php-fpm -D && exec nginx -g 'daemon off;'"]
|