- add mysql client binaries for database operations - reduce php extensions to production essentials - bind mysql and phpmyadmin to localhost only - replace php-fpm.conf with php.ini for upload limits
42 lines
1.2 KiB
Docker
42 lines
1.2 KiB
Docker
FROM mysql:8.0 AS mysql
|
|
|
|
FROM php:8.3-fpm
|
|
|
|
COPY --from=mysql /usr/bin/mysql /usr/bin/mysql
|
|
COPY --from=mysql /usr/bin/mysqldump /usr/bin/mysqldump
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
libonig-dev \
|
|
gosu netcat-traditional \
|
|
&& docker-php-ext-install pdo_mysql mbstring \
|
|
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
|
|
|
ARG UID
|
|
ARG GID
|
|
|
|
# Create a new user with the specified UID and GID, reusing an existing group if GID exists
|
|
RUN if getent group ${GID}; then \
|
|
group_name=$(getent group ${GID} | cut -d: -f1); \
|
|
useradd -m -u ${UID} -g ${GID} -s /bin/bash www; \
|
|
else \
|
|
groupadd -g ${GID} www && \
|
|
useradd -m -u ${UID} -g www -s /bin/bash www; \
|
|
group_name=www; \
|
|
fi
|
|
|
|
# Update php-fpm to use the new user and group
|
|
RUN sed -i "s/user = www-data/user = www/g" /usr/local/etc/php-fpm.d/www.conf && \
|
|
sed -i "s/group = www-data/group = $group_name/g" /usr/local/etc/php-fpm.d/www.conf
|
|
|
|
COPY --chmod=644 ./docker/php.ini /usr/local/etc/php/conf.d/laravel.ini
|
|
|
|
COPY ./docker/entrypoint.sh /usr/local/bin/
|
|
RUN chmod +x /usr/local/bin/entrypoint.sh
|
|
|
|
WORKDIR /var/www
|
|
EXPOSE 9000
|
|
ENTRYPOINT ["entrypoint.sh"]
|
|
CMD ["php-fpm"]
|