add two more
This commit is contained in:
parent
6a785f5ab2
commit
b8508627bf
|
|
@ -48,7 +48,7 @@ services:
|
|||
network: host
|
||||
|
||||
volumes:
|
||||
- ./:/var/www/html:rw
|
||||
- ./:/var/www/html:ro
|
||||
|
||||
depends_on:
|
||||
- mariadb
|
||||
|
|
|
|||
|
|
@ -1,34 +1,49 @@
|
|||
# =========================
|
||||
# Stage 1: Dependencies
|
||||
# =========================
|
||||
FROM composer:2 AS vendor
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY composer.json composer.lock ./
|
||||
|
||||
# install dependencies cleanly (NO MIRROR, NO DEV)
|
||||
RUN composer install \
|
||||
--no-dev \
|
||||
--prefer-dist \
|
||||
--no-interaction \
|
||||
--optimize-autoloader
|
||||
|
||||
# =========================
|
||||
# Stage 2: Runtime
|
||||
# =========================
|
||||
FROM php:8.2-fpm-bookworm
|
||||
|
||||
ARG LINUX_REGISTRY="http://mirror.arvancloud.ir/debian"
|
||||
ARG SECURITY_REGISTRY="http://mirror.arvancloud.ir/debian-security"
|
||||
# تغییر سورسهای apt
|
||||
#RUN sed -i "s|http://deb.debian.org/debian|${LINUX_REGISTRY}|g" /etc/apt/sources.list.d/debian.sources \
|
||||
# && sed -i "s|http://security.debian.org/debian-security|${SECURITY_REGISTRY}|g" /etc/apt/sources.list.d/debian.sources \
|
||||
# && echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/99ignore \
|
||||
# && echo 'Acquire::AllowInsecureRepositories "true";' >> /etc/apt/apt.conf.d/99ignore
|
||||
|
||||
# نصب nodejs و npm در کنار سایر وابستگیها
|
||||
RUN apt-get update && apt-get install -y --allow-downgrades --no-install-recommends \
|
||||
libzip-dev \
|
||||
unzip \
|
||||
git \
|
||||
curl \
|
||||
gnupg2 \
|
||||
ca-certificates \
|
||||
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
|
||||
RUN install-php-extensions zip bcmath pdo pdo_mysql
|
||||
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
WORKDIR /var/www/html
|
||||
ENV COMPOSER_ALLOW_SUPERUSER=1
|
||||
|
||||
RUN echo "pcre.jit=0" > /usr/local/etc/php/conf.d/disable-pcre-jit.ini
|
||||
# system deps
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
unzip \
|
||||
libzip-dev \
|
||||
curl \
|
||||
&& docker-php-ext-install pdo pdo_mysql zip \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# اضافه کردن Entrypoint
|
||||
COPY ./docker/php/entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||
# copy vendor from stage 1
|
||||
COPY --from=vendor /app/vendor ./vendor
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||
# copy project files
|
||||
COPY . .
|
||||
|
||||
# permissions
|
||||
RUN chown -R www-data:www-data /var/www/html
|
||||
|
||||
# entrypoint
|
||||
COPY ./docker/php/entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
EXPOSE 9000
|
||||
CMD ["php-fpm"]
|
||||
|
|
|
|||
|
|
@ -1,36 +1,30 @@
|
|||
#!/bin/bash
|
||||
|
||||
# توقف در صورت بروز خطای مهلک
|
||||
set -e
|
||||
|
||||
echo "[+] Starting Initialization Process..."
|
||||
echo "[+] Laravel container starting..."
|
||||
|
||||
# ۱. نصب وابستگیهای PHP با نادیده گرفتن پکیجهای Dev
|
||||
echo "[+] Installing PHP dependencies via Composer..."
|
||||
composer clear-cache
|
||||
composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev
|
||||
if [ ! -d vendor ]; then
|
||||
echo "[!] vendor not found, stopping"
|
||||
# .env
|
||||
if [ ! -f .env ]; then
|
||||
echo "[+] Creating .env"
|
||||
cp .env.example .env
|
||||
fi
|
||||
|
||||
# safety check
|
||||
if [ ! -f vendor/autoload.php ]; then
|
||||
echo "[❌] vendor missing! build image again"
|
||||
exit 1
|
||||
fi
|
||||
# ۲. پیکربندی محیط (Environment) لاراول
|
||||
if [ ! -f .env ]; then
|
||||
echo "[+] .env file not found. Creating from .env.example..."
|
||||
cp .env.example .env
|
||||
else
|
||||
echo "[+] .env file already exists."
|
||||
|
||||
# key generate only if not set
|
||||
if ! grep -q "APP_KEY=base64" .env; then
|
||||
echo "[+] Generating APP KEY"
|
||||
php artisan key:generate --no-interaction
|
||||
fi
|
||||
|
||||
# ۳. تولید کلید امنیتی لاراول (App Key)
|
||||
echo "[+] Generating App Key..."
|
||||
php artisan key:generate --no-interaction
|
||||
# cache optimize (optional but good)
|
||||
php artisan config:cache || true
|
||||
php artisan route:cache || true
|
||||
|
||||
echo "[+] Starting PHP-FPM..."
|
||||
|
||||
|
||||
# ۶. آمادهسازی پایگاه داده
|
||||
echo "[+] Running database migrations..."
|
||||
# از سوییچ force استفاده میکنیم تا در محیط غیرتعاملی ارور ندهد
|
||||
php artisan migrate --force
|
||||
# ۷. اجرای سرویس اصلی
|
||||
echo "[+] Starting PHP-FPM for Browser-Sec-Lab..."
|
||||
exec php-fpm
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user