ci: setup Dockerfile, GitLab CI pipeline, and Helm chart for Rancher
This commit is contained in:
+38
-139
@@ -1,151 +1,50 @@
|
||||
# =========================================================
|
||||
# APPLICATION STAGE
|
||||
# Laravel + PHP 7.4 + OCI8 + Nginx
|
||||
# =========================================================
|
||||
|
||||
FROM 10.15.39.186:8083/php74-fpm-oci8-lengkap:1.0
|
||||
|
||||
# =========================================================
|
||||
# Proxy
|
||||
# =========================================================
|
||||
# Arahkan repository APT ke Nexus Debian Proxy lokal
|
||||
RUN sed -i 's|http://deb.debian.org/debian|http://10.15.39.186:8081/repository/debian-proxy|g' /etc/apt/sources.list \
|
||||
&& sed -i 's|http://security.debian.org/debian-security|http://10.15.39.186:8081/repository/debian-proxy|g' /etc/apt/sources.list \
|
||||
&& sed -i 's|http://security.debian.org|http://10.15.39.186:8081/repository/debian-proxy|g' /etc/apt/sources.list 2>/dev/null || true
|
||||
|
||||
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}
|
||||
|
||||
# =========================================================
|
||||
# System dependencies & Extensions
|
||||
# =========================================================
|
||||
|
||||
RUN echo "deb [trusted=yes] http://10.15.39.186:8081/repository/debian-proxy/ bullseye main" > /etc/apt/sources.list \
|
||||
&& echo "deb [trusted=yes] http://10.15.39.186:8081/repository/debian-proxy/ bullseye-updates main" >> /etc/apt/sources.list \
|
||||
&& rm -rf /etc/apt/sources.list.d/* \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
nginx \
|
||||
vim \
|
||||
wget \
|
||||
curl \
|
||||
libpng-dev \
|
||||
libjpeg-dev \
|
||||
libfreetype6-dev \
|
||||
libzip-dev \
|
||||
libaio1 \
|
||||
libaio-dev \
|
||||
unzip \
|
||||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
||||
&& docker-php-ext-install gd pdo pdo_mysql zip \
|
||||
&& curl --noproxy "*" -fsSL http://10.15.39.186:8081/repository/raw-assets/storage/app/uploads/redis-5.3.7.tgz -o redis.tgz \
|
||||
&& pecl install redis.tgz \
|
||||
&& docker-php-ext-enable redis \
|
||||
&& rm -f redis.tgz \
|
||||
# Install Nginx dan dependensi kompilasi
|
||||
RUN apt-get update && apt-get install -y \
|
||||
nginx \
|
||||
curl \
|
||||
autoconf \
|
||||
g++ \
|
||||
make \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# =========================================================
|
||||
# PEAR Proxy (jika diperlukan)
|
||||
# =========================================================
|
||||
# Unduh dan pasang ekstensi PHP Redis dari repository Nexus
|
||||
RUN curl -o /tmp/redis-5.3.7.tgz http://10.15.39.186:8081/repository/raw-assets/storage/app/uploads/redis-5.3.7.tgz \
|
||||
&& pecl install /tmp/redis-5.3.7.tgz \
|
||||
&& docker-php-ext-enable redis \
|
||||
&& rm -f /tmp/redis-5.3.7.tgz
|
||||
|
||||
RUN pear config-set http_proxy "http://10.15.3.20:80" || true
|
||||
WORKDIR /var/www/html
|
||||
|
||||
# =========================================================
|
||||
# Composer setup & Caching Layer
|
||||
# =========================================================
|
||||
# Salin source code aplikasi
|
||||
COPY . /var/www/html
|
||||
|
||||
WORKDIR /var/www
|
||||
# Atur hak akses folder storage dan cache Laravel
|
||||
RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache \
|
||||
&& chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache
|
||||
|
||||
# Copy composer files terlebih dahulu agar Docker Caching layer aktif
|
||||
COPY composer.json composer.lock ./
|
||||
|
||||
RUN composer install \
|
||||
--no-dev \
|
||||
--prefer-dist \
|
||||
--no-interaction \
|
||||
--no-scripts \
|
||||
--optimize-autoloader
|
||||
|
||||
# Copy seluruh source code project
|
||||
COPY --chown=www-data:www-data . .
|
||||
|
||||
# =========================================================
|
||||
# Laravel directories & permission
|
||||
# =========================================================
|
||||
|
||||
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 \
|
||||
&& chmod -R 775 /var/www/bootstrap/cache
|
||||
|
||||
# =========================================================
|
||||
# Laravel cache cleanup
|
||||
# =========================================================
|
||||
|
||||
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
|
||||
|
||||
# =========================================================
|
||||
# Clear Proxy Environment Variables from Runtime
|
||||
# =========================================================
|
||||
|
||||
ENV http_proxy=""
|
||||
ENV https_proxy=""
|
||||
ENV HTTP_PROXY=""
|
||||
ENV HTTPS_PROXY=""
|
||||
|
||||
# =========================================================
|
||||
# Execution
|
||||
# =========================================================
|
||||
# Konfigurasi Nginx
|
||||
RUN echo 'server { \
|
||||
listen 80; \
|
||||
index index.php index.html; \
|
||||
root /var/www/html/public; \
|
||||
location / { \
|
||||
try_files $uri $uri/ /index.php?$query_string; \
|
||||
} \
|
||||
location ~ \.php$ { \
|
||||
fastcgi_pass 127.0.0.1:9000; \
|
||||
fastcgi_index index.php; \
|
||||
include fastcgi_params; \
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; \
|
||||
} \
|
||||
}' > /etc/nginx/sites-available/default
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["sh", "-c", "php-fpm -D && exec nginx -g 'daemon off;'"]
|
||||
CMD ["sh", "-c", "php-fpm -D && nginx -g 'daemon off;'"]
|
||||
Reference in New Issue
Block a user