add two more
This commit is contained in:
parent
6a785f5ab2
commit
b8508627bf
|
|
@ -48,7 +48,7 @@ services:
|
||||||
network: host
|
network: host
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./:/var/www/html:rw
|
- ./:/var/www/html:ro
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- mariadb
|
- 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
|
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
|
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 vendor from stage 1
|
||||||
COPY ./docker/php/entrypoint.sh /usr/local/bin/entrypoint.sh
|
COPY --from=vendor /app/vendor ./vendor
|
||||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
|
||||||
|
|
||||||
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
|
#!/bin/bash
|
||||||
|
|
||||||
# توقف در صورت بروز خطای مهلک
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "[+] Starting Initialization Process..."
|
echo "[+] Laravel container starting..."
|
||||||
|
|
||||||
# ۱. نصب وابستگیهای PHP با نادیده گرفتن پکیجهای Dev
|
# .env
|
||||||
echo "[+] Installing PHP dependencies via Composer..."
|
if [ ! -f .env ]; then
|
||||||
composer clear-cache
|
echo "[+] Creating .env"
|
||||||
composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev
|
cp .env.example .env
|
||||||
if [ ! -d vendor ]; then
|
fi
|
||||||
echo "[!] vendor not found, stopping"
|
|
||||||
|
# safety check
|
||||||
|
if [ ! -f vendor/autoload.php ]; then
|
||||||
|
echo "[❌] vendor missing! build image again"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# ۲. پیکربندی محیط (Environment) لاراول
|
|
||||||
if [ ! -f .env ]; then
|
# key generate only if not set
|
||||||
echo "[+] .env file not found. Creating from .env.example..."
|
if ! grep -q "APP_KEY=base64" .env; then
|
||||||
cp .env.example .env
|
echo "[+] Generating APP KEY"
|
||||||
else
|
php artisan key:generate --no-interaction
|
||||||
echo "[+] .env file already exists."
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ۳. تولید کلید امنیتی لاراول (App Key)
|
# cache optimize (optional but good)
|
||||||
echo "[+] Generating App Key..."
|
php artisan config:cache || true
|
||||||
php artisan key:generate --no-interaction
|
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
|
exec php-fpm
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user