hosting-backend/Dockerfile
Alexis Bruneteau f5560f4aea
Some checks failed
Build and Deploy to k3s / build-and-deploy (push) Failing after 28s
fixed database right
2025-06-02 15:54:58 +02:00

69 lines
1.5 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
# 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
# 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"]