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
|
FROM php:8.2-cli-alpine AS build
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install dependencies required for Composer and Laravel
|
# Install Composer and build dependencies
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
libzip-dev \
|
libzip-dev zip unzip curl git oniguruma-dev libxml2-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
|
RUN docker-php-ext-install zip mbstring xml
|
||||||
|
|
||||||
# Install Composer
|
# Install Composer
|
||||||
RUN curl -sS https://getcomposer.org/installer | php && \
|
RUN curl -sS https://getcomposer.org/installer | php && \
|
||||||
mv composer.phar /usr/local/bin/composer
|
mv composer.phar /usr/local/bin/composer
|
||||||
|
|
||||||
# Copy application files and install dependencies
|
# Copy project files and install dependencies
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN composer install --no-dev --optimize-autoloader --no-interaction
|
RUN composer install --no-dev --optimize-autoloader --no-interaction
|
||||||
|
|
||||||
# Stage 2: Final image
|
|
||||||
|
# ---------- Stage 2: Production Image ----------
|
||||||
FROM php:8.2-fpm-alpine
|
FROM php:8.2-fpm-alpine
|
||||||
|
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /var/www
|
WORKDIR /var/www
|
||||||
|
|
||||||
# Install system dependencies and PHP extensions
|
# Install system and PHP dependencies
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
nginx \
|
nginx \
|
||||||
supervisor \
|
supervisor \
|
||||||
@ -41,48 +36,41 @@ RUN apk add --no-cache \
|
|||||||
freetype-dev \
|
freetype-dev \
|
||||||
libxml2-dev \
|
libxml2-dev \
|
||||||
oniguruma-dev \
|
oniguruma-dev \
|
||||||
zip \
|
libzip-dev \
|
||||||
unzip \
|
|
||||||
curl \
|
curl \
|
||||||
shadow
|
git \
|
||||||
|
openssh \
|
||||||
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 \
|
|
||||||
python3 \
|
python3 \
|
||||||
py3-pip \
|
py3-pip \
|
||||||
build-base \
|
php-dev \
|
||||||
libffi-dev \
|
php-pear \
|
||||||
openssl-dev \
|
gcc g++ make autoconf libtool linux-headers
|
||||||
python3-dev \
|
|
||||||
rust \
|
|
||||||
cargo \
|
|
||||||
&& pip3 install --upgrade pip \
|
|
||||||
&& pip3 install ansible \
|
|
||||||
&& apk del build-base rust cargo
|
|
||||||
|
|
||||||
|
|
||||||
# Install PHP extensions
|
# Install PHP extensions
|
||||||
RUN docker-php-ext-configure gd --with-freetype --with-jpeg && \
|
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
|
COPY --from=build /app /var/www
|
||||||
|
|
||||||
RUN chown -R www-data:www-data storage bootstrap/cache database &&\
|
# Set proper permissions for Laravel
|
||||||
chmod -R 755 /var/www/storage /var/www/bootstrap/cache database
|
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 config files
|
||||||
# Copy custom nginx and supervisord config
|
|
||||||
COPY deploy/nginx.conf /etc/nginx/nginx.conf
|
COPY deploy/nginx.conf /etc/nginx/nginx.conf
|
||||||
COPY deploy/supervisord.conf /etc/supervisord.conf
|
COPY deploy/supervisord.conf /etc/supervisord.conf
|
||||||
|
|
||||||
# Expose port
|
# Expose HTTP port
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
# Run both services
|
# Start services
|
||||||
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]
|
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user