random-web-tools/Dockerfile
stuzer05 4213120218
All checks were successful
build docker image / docker-build (push) Successful in 2m5s
Add dummy files tool
2024-11-13 21:08:41 +02:00

92 lines
3.1 KiB
Docker

# Build stage
FROM node:18-alpine AS node-builder
WORKDIR /app
COPY . .
RUN npm install -g vite \
&& npm install \
&& npm run build
# PHP stage
FROM php:8.3-fpm-alpine
# Install system packages
RUN apk add --no-cache \
nginx \
supervisor \
curl \
nano \
gettext \
icu-libs \
libzip \
bzip2 \
libxslt \
oniguruma \
sqlite-libs
# Install PHP modules
RUN apk add --no-cache --virtual .build-deps \
icu-dev \
libzip-dev \
freetype-dev \
libpng-dev \
libjpeg-turbo-dev \
libwebp-dev \
bzip2-dev \
curl-dev \
tidyhtml-dev \
libxslt-dev \
oniguruma-dev \
sqlite-dev \
&& docker-php-ext-install -j$(nproc) \
mbstring \
xml \
dom \
zip \
intl \
curl \
calendar \
pdo_sqlite \
bcmath \
&& apk del .build-deps
# Configure php-fpm
RUN rm /usr/local/etc/php-fpm.d/www.conf.default \
&& sed -i 's/listen = 127.0.0.1:9000/listen = \/run\/php\/php-fpm.sock/' /usr/local/etc/php-fpm.d/www.conf \
&& sed -i 's/;listen.owner = www-data/listen.owner = www-data/' /usr/local/etc/php-fpm.d/www.conf \
&& sed -i 's/;listen.group = www-data/listen.group = www-data/' /usr/local/etc/php-fpm.d/www.conf \
&& sed -i 's/;listen.mode = 0660/listen.mode = 0660/' /usr/local/etc/php-fpm.d/www.conf \
&& sed -i 's/;clear_env = no/clear_env = no/' /usr/local/etc/php-fpm.d/www.conf \
&& cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini \
&& sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 200M/' /usr/local/etc/php/php.ini \
&& sed -i 's/post_max_size = 8M/post_max_size = 200M/' /usr/local/etc/php/php.ini \
&& sed -i 's/error_log = \/proc\/self\/fd\/2/error_log = \/proc\/self\/fd\/2/' /usr/local/etc/php-fpm.d/docker.conf \
&& sed -i 's/;error_log = syslog/error_log = \/proc\/self\/fd\/2/' /usr/local/etc/php-fpm.d/www.conf \
&& sed -i 's/;access.log = \/proc\/self\/fd\/2/access.log = \/proc\/self\/fd\/2/' /usr/local/etc/php-fpm.d/www.conf \
&& sed -i 's/;catch_workers_output = yes/catch_workers_output = yes/' /usr/local/etc/php-fpm.d/www.conf \
&& sed -i 's/;php_admin_flag\[log_errors\] = on/php_admin_flag[log_errors] = on/' /usr/local/etc/php-fpm.d/www.conf \
&& sed -i 's/;php_admin_value\[error_log\] = .*/php_admin_value[error_log] = \/proc\/self\/fd\/2/' /usr/local/etc/php-fpm.d/www.conf \
#&& sed -i 's/display_errors = Off/display_errors = On/' /usr/local/etc/php/php.ini \
&& sed -i 's/log_errors = Off/log_errors = On/' /usr/local/etc/php/php.ini
# Copy configurations
COPY ./docker/conf/etc /etc
# Copy built application from node stage
COPY --from=node-builder /app/dist /var/www/html
COPY --from=node-builder /app/api /var/www/html/api
COPY --from=node-builder /app/static /var/www/html/static
# Set permissions
RUN chown -R www-data:www-data /var/www/html
# Create system dirs
RUN mkdir -p /var/run && \
mkdir -p /run/php
# Copy and set entrypoint
COPY ./entrypoint.sh /
RUN chmod +x /entrypoint.sh
CMD ["/bin/sh", "/entrypoint.sh"]