Fix: optimize Dockerfile caching layer and retry apt network requests
This commit is contained in:
+15
-23
@@ -18,10 +18,10 @@ ENV HTTP_PROXY=${http_proxy}
|
|||||||
ENV HTTPS_PROXY=${https_proxy}
|
ENV HTTPS_PROXY=${https_proxy}
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# System dependencies
|
# System dependencies & Extensions
|
||||||
# =========================================================
|
# =========================================================
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update -o Acquire::Retries=5 && apt-get install -y --no-install-recommends --fix-missing \
|
||||||
nginx \
|
nginx \
|
||||||
vim \
|
vim \
|
||||||
wget \
|
wget \
|
||||||
@@ -40,29 +40,25 @@ RUN apt-get update && apt-get install -y \
|
|||||||
pdo \
|
pdo \
|
||||||
pdo_mysql \
|
pdo_mysql \
|
||||||
zip \
|
zip \
|
||||||
|
&& pecl install redis \
|
||||||
|
&& docker-php-ext-enable redis \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# PEAR Proxy
|
# PEAR Proxy (jika diperlukan)
|
||||||
# =========================================================
|
# =========================================================
|
||||||
|
|
||||||
RUN pear config-set http_proxy "http://10.15.3.20:80"
|
RUN pear config-set http_proxy "http://10.15.3.20:80" || true
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Composer
|
# Composer setup & Caching Layer
|
||||||
# =========================================================
|
# =========================================================
|
||||||
|
|
||||||
WORKDIR /var/www
|
WORKDIR /var/www
|
||||||
|
|
||||||
# =========================================================
|
# Copy file composer terlebih dahulu agar Docker Cache aktif
|
||||||
# Composer dependency
|
|
||||||
# Copy hanya composer files terlebih dahulu agar Docker cache
|
|
||||||
# =========================================================
|
|
||||||
|
|
||||||
COPY composer.json composer.lock ./
|
COPY composer.json composer.lock ./
|
||||||
|
|
||||||
COPY --chown=www-data:www-data . .
|
|
||||||
|
|
||||||
RUN composer install \
|
RUN composer install \
|
||||||
--no-dev \
|
--no-dev \
|
||||||
--prefer-dist \
|
--prefer-dist \
|
||||||
@@ -70,6 +66,9 @@ RUN composer install \
|
|||||||
--no-scripts \
|
--no-scripts \
|
||||||
--optimize-autoloader
|
--optimize-autoloader
|
||||||
|
|
||||||
|
# Copy seluruh source code setelah composer install selesai
|
||||||
|
COPY --chown=www-data:www-data . .
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Laravel directories & permission
|
# Laravel directories & permission
|
||||||
# =========================================================
|
# =========================================================
|
||||||
@@ -86,7 +85,7 @@ RUN mkdir -p \
|
|||||||
&& chmod -R 775 /var/www/bootstrap/cache
|
&& chmod -R 775 /var/www/bootstrap/cache
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Laravel cache
|
# Laravel cache cleanup
|
||||||
# =========================================================
|
# =========================================================
|
||||||
|
|
||||||
RUN php artisan config:clear || true \
|
RUN php artisan config:clear || true \
|
||||||
@@ -130,14 +129,11 @@ RUN printf '%s\n' \
|
|||||||
'}' \
|
'}' \
|
||||||
> /etc/nginx/sites-available/default
|
> /etc/nginx/sites-available/default
|
||||||
|
|
||||||
RUN pecl install redis \
|
|
||||||
&& docker-php-ext-enable redis
|
|
||||||
|
|
||||||
RUN ln -sf /etc/nginx/sites-available/default \
|
RUN ln -sf /etc/nginx/sites-available/default \
|
||||||
/etc/nginx/sites-enabled/default
|
/etc/nginx/sites-enabled/default
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Remove proxy from runtime
|
# Clear Proxy Environment Variables from Runtime
|
||||||
# =========================================================
|
# =========================================================
|
||||||
|
|
||||||
ENV http_proxy=""
|
ENV http_proxy=""
|
||||||
@@ -146,13 +142,9 @@ ENV HTTP_PROXY=""
|
|||||||
ENV HTTPS_PROXY=""
|
ENV HTTPS_PROXY=""
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Port
|
# Execution
|
||||||
# =========================================================
|
# =========================================================
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
# =========================================================
|
CMD ["sh", "-c", "php-fpm -D && exec nginx -g 'daemon off;'"]
|
||||||
# Start PHP-FPM + Nginx
|
|
||||||
# =========================================================
|
|
||||||
|
|
||||||
CMD ["sh", "-c", "php-fpm -D && exec nginx -g 'daemon off;'"]
|
|
||||||
Reference in New Issue
Block a user