This commit is contained in:
parent
7850dfedc8
commit
ed8934f597
72
Dockerfile
72
Dockerfile
@ -1,36 +1,31 @@
|
||||
# Stage 1: Build with Composer
|
||||
# ---------- Stage 1: Build with Composer ----------
|
||||
FROM php:8.2-cli-alpine AS build
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies required for Composer and Laravel
|
||||
# Install Composer and build dependencies
|
||||
RUN apk add --no-cache \
|
||||
libzip-dev \
|
||||
zip \
|
||||
unzip \
|
||||
curl \
|
||||
git \
|
||||
oniguruma-dev \
|
||||
libxml2-dev
|
||||
libzip-dev zip unzip curl git oniguruma-dev libxml2-dev
|
||||
|
||||
# Install PHP extensions
|
||||
# Install PHP extensions for Laravel
|
||||
RUN docker-php-ext-install zip mbstring xml
|
||||
|
||||
# Install Composer
|
||||
RUN curl -sS https://getcomposer.org/installer | php && \
|
||||
mv composer.phar /usr/local/bin/composer
|
||||
|
||||
# Copy application files and install dependencies
|
||||
# Copy project files and install dependencies
|
||||
COPY . .
|
||||
RUN composer install --no-dev --optimize-autoloader --no-interaction
|
||||
|
||||
# Stage 2: Final image
|
||||
|
||||
# ---------- Stage 2: Production Image ----------
|
||||
FROM php:8.2-fpm-alpine
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /var/www
|
||||
|
||||
# Install system dependencies and PHP extensions
|
||||
# Install system and PHP dependencies
|
||||
RUN apk add --no-cache \
|
||||
nginx \
|
||||
supervisor \
|
||||
@ -41,48 +36,41 @@ RUN apk add --no-cache \
|
||||
freetype-dev \
|
||||
libxml2-dev \
|
||||
oniguruma-dev \
|
||||
zip \
|
||||
unzip \
|
||||
libzip-dev \
|
||||
curl \
|
||||
shadow
|
||||
|
||||
RUN apk --no-cache add pcre-dev ${PHPIZE_DEPS} \
|
||||
&& pecl install redis \
|
||||
&& docker-php-ext-enable redis \
|
||||
&& apk del pcre-dev ${PHPIZE_DEPS} \
|
||||
&& rm -rf /tmp/pear
|
||||
|
||||
RUN apk add --no-cache \
|
||||
git \
|
||||
openssh \
|
||||
python3 \
|
||||
py3-pip \
|
||||
build-base \
|
||||
libffi-dev \
|
||||
openssl-dev \
|
||||
python3-dev \
|
||||
rust \
|
||||
cargo \
|
||||
&& pip3 install --upgrade pip \
|
||||
&& pip3 install ansible \
|
||||
&& apk del build-base rust cargo
|
||||
|
||||
php-dev \
|
||||
php-pear \
|
||||
gcc g++ make autoconf libtool linux-headers
|
||||
|
||||
# Install PHP extensions
|
||||
RUN docker-php-ext-configure gd --with-freetype --with-jpeg && \
|
||||
docker-php-ext-install pdo pdo_mysql mbstring gd xml
|
||||
docker-php-ext-install pdo pdo_mysql mbstring gd xml zip && \
|
||||
pecl install redis && \
|
||||
docker-php-ext-enable redis
|
||||
|
||||
# Copy files from build stage
|
||||
# Clean up build tools
|
||||
RUN apk del gcc g++ make autoconf php-dev libtool
|
||||
|
||||
# Install Ansible
|
||||
RUN pip install --no-cache-dir ansible
|
||||
|
||||
# Copy built app from previous stage
|
||||
COPY --from=build /app /var/www
|
||||
|
||||
RUN chown -R www-data:www-data storage bootstrap/cache database &&\
|
||||
chmod -R 755 /var/www/storage /var/www/bootstrap/cache database
|
||||
# Set proper permissions for Laravel
|
||||
RUN chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache /var/www/database && \
|
||||
chmod -R 755 /var/www/storage /var/www/bootstrap/cache /var/www/database
|
||||
|
||||
|
||||
# Copy custom nginx and supervisord config
|
||||
# Copy config files
|
||||
COPY deploy/nginx.conf /etc/nginx/nginx.conf
|
||||
COPY deploy/supervisord.conf /etc/supervisord.conf
|
||||
|
||||
# Expose port
|
||||
# Expose HTTP port
|
||||
EXPOSE 80
|
||||
|
||||
# Run both services
|
||||
# Start services
|
||||
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user