hosting-backend/Dockerfile
Alexis Bruneteau fb79cbc432
Some checks failed
Build and Deploy to k3s / build-and-deploy (push) Failing after 10s
tag
2025-06-05 03:56:54 +02:00

76 lines
1.7 KiB
Docker

# Stage 1: Build with Composer
FROM php:8.2-cli-alpine AS build
WORKDIR /app
# Install dependencies required for Composer and Laravel
RUN apk add --no-cache \
libzip-dev \
zip \
unzip \
curl \
git \
oniguruma-dev \
libxml2-dev
# Install PHP extensions
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 . .
RUN composer install --no-dev --optimize-autoloader --no-interaction
# Stage 2: Final image
FROM php:8.2-fpm-alpine
# Set working directory
WORKDIR /var/www
# Install system dependencies and PHP extensions
RUN apk add --no-cache \
nginx \
supervisor \
bash \
mysql-client \
libpng-dev \
libjpeg-turbo-dev \
freetype-dev \
libxml2-dev \
oniguruma-dev \
zip \
unzip \
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} s\
&& rm -rf /tmp/pear \
# Install PHP extensions
RUN docker-php-ext-configure gd --with-freetype --with-jpeg && \
docker-php-ext-install pdo pdo_mysql mbstring gd xml
# Copy files from build 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
# Copy custom nginx and supervisord config
COPY deploy/nginx.conf /etc/nginx/nginx.conf
COPY deploy/supervisord.conf /etc/supervisord.conf
# Expose port
EXPOSE 80
# Run both services
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]