update git
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m8s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 15s
Build, Push and Deploy / deploy-staging (push) Successful in 26s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 0s

This commit is contained in:
2026-03-31 08:27:42 +07:00
parent 8fb1995913
commit f2c19ec025
2 changed files with 137 additions and 45 deletions

View File

@@ -1,60 +1,92 @@
FROM php:8.4-fpm FROM php:8.2-fpm-alpine
# 1. Setup NodeSource untuk instalasi Node.js v20 (Cepat & Stabil) # Install system dependencies
RUN apt-get update && apt-get install -y ca-certificates curl gnupg \ RUN apk add --no-cache \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ vim \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list xxd \
# 2. Install dependencies utama dengan apt-get
RUN apt-get update && apt-get install -y \
git \
libpng-dev \
libonig-dev \
libxml2-dev \
libpq-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libzip-dev \ libzip-dev \
zip \ postgresql-dev \
unzip \ libpng-dev \
libjpeg-turbo-dev \
freetype-dev \
oniguruma-dev \
git \
curl \
nodejs \ nodejs \
&& apt-get clean && rm -rf /var/lib/apt/lists/* npm \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) \
pdo_pgsql \
pgsql \
opcache \
zip \
bcmath \
gd \
exif \
pcntl
# 3. Install PHP Extensions (TERMASUK pgsql / pdo_pgsql) # Configure git to allow safe directory
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \ RUN git config --global --add safe.directory /var/www/html
&& docker-php-ext-install pdo_mysql pdo_pgsql pgsql mbstring exif pcntl bcmath gd zip
# 4. Get latest Composer # Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
WORKDIR /var/www WORKDIR /var/www/html
# 5. Copy existing application directory contents # Copy ONLY composer files first
COPY . /var/www COPY composer.json ./
# 5.5 PASTIKAN FOLDER CACHE & STORAGE TERBUAT SEBELUM COMPOSER RUN # Create storage and bootstrap directories needed for composer scripts
RUN mkdir -p /var/www/storage/framework/cache/data \ RUN mkdir -p storage/framework/cache \
/var/www/storage/framework/sessions \ && mkdir -p storage/framework/sessions \
/var/www/storage/framework/views \ && mkdir -p storage/framework/views \
/var/www/storage/framework/testing \ && mkdir -p storage/framework/testing \
/var/www/storage/logs \ && mkdir -p storage/logs \
/var/www/bootstrap/cache && mkdir -p bootstrap/cache \
&& chmod -R 777 storage \
&& chmod -R 777 bootstrap/cache
# 6. Install dependencies # Configure Composer for stability on unstable networks
ENV COMPOSER_ALLOW_SUPERUSER=1 \ ENV COMPOSER_ALLOW_SUPERUSER=1 \
COMPOSER_MEMORY_LIMIT=-1 COMPOSER_MEMORY_LIMIT=-1 \
RUN composer install --no-interaction --optimize-autoloader COMPOSER_PROCESS_TIMEOUT=2000
# 7. Install & Build Frontend # Install PHP dependencies (this layer will be cached)
RUN npm install RUN composer config -g repo.packagist composer https://packagist.org \
&& composer install --no-interaction --no-progress --no-scripts --prefer-dist
# Isolate the clean vendor directory
#RUN mv vendor /vendor_clean
# Copy the rest of the application files (will ignore vendor because of .dockerignore)
COPY --chown=www-data:www-data . .
# Restore the clean vendor directory and set proper permissions
#RUN rm -rf vendor && mv /vendor_clean vendor && chown -R www-data:www-data vendor
# Final build verification
RUN if [ ! -f vendor/laravel/prompts/src/helpers.php ]; then \
echo "ERROR: laravel/prompts/src/helpers.php missing!" && exit 1; \
fi
# Final check and debug listing
RUN ls -l vendor/laravel/prompts/src/helpers.php \
&& du -sh vendor/laravel/prompts
# Copy package files for NPM
COPY package*.json ./
COPY vite.config.js ./
# Install NPM dependencies
RUN npm install --legacy-peer-deps --no-audit
# Build Vite assets
RUN npm run build RUN npm run build
# 8. Set permissions # Copy entrypoint script and ensure it's executable
RUN chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache \ COPY entrypoint.sh /entrypoint.sh
&& chmod -R 775 /var/www/storage /var/www/bootstrap/cache RUN chmod +x /entrypoint.sh
# 9. Expose port 8000 and start php artisan serve # Let the entrypoint handle artisan commands at runtime
EXPOSE 8000 EXPOSE 8000 9000
ENTRYPOINT ["/entrypoint.sh"]
# artisan serve berjalan langsung
CMD ["php", "artisan", "serve", "--host=0.0.0.0", "--port=8000"]

60
dockerfile2.txt Normal file
View File

@@ -0,0 +1,60 @@
FROM php:8.4-fpm
# 1. Setup NodeSource untuk instalasi Node.js v20 (Cepat & Stabil)
RUN apt-get update && apt-get install -y ca-certificates curl gnupg \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
# 2. Install dependencies utama dengan apt-get
RUN apt-get update && apt-get install -y \
git \
libpng-dev \
libonig-dev \
libxml2-dev \
libpq-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libzip-dev \
zip \
unzip \
nodejs \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# 3. Install PHP Extensions (TERMASUK pgsql / pdo_pgsql)
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install pdo_mysql pdo_pgsql pgsql mbstring exif pcntl bcmath gd zip
# 4. Get latest Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
WORKDIR /var/www
# 5. Copy existing application directory contents
COPY . /var/www
# 5.5 PASTIKAN FOLDER CACHE & STORAGE TERBUAT SEBELUM COMPOSER RUN
RUN mkdir -p /var/www/storage/framework/cache/data \
/var/www/storage/framework/sessions \
/var/www/storage/framework/views \
/var/www/storage/framework/testing \
/var/www/storage/logs \
/var/www/bootstrap/cache
# 6. Install dependencies
ENV COMPOSER_ALLOW_SUPERUSER=1 \
COMPOSER_MEMORY_LIMIT=-1
RUN composer install --no-interaction --optimize-autoloader
# 7. Install & Build Frontend
RUN npm install
RUN npm run build
# 8. Set permissions
RUN chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache \
&& chmod -R 775 /var/www/storage /var/www/bootstrap/cache
# 9. Expose port 8000 and start php artisan serve
EXPOSE 8000
# artisan serve berjalan langsung
CMD ["php", "artisan", "serve", "--host=0.0.0.0", "--port=8000"]