random-web-tools/Dockerfile

93 lines
3.1 KiB
Docker
Raw Normal View History

2024-11-05 11:03:22 +02:00
# Build stage
FROM node:18-alpine AS node-builder
2024-11-04 16:45:27 +02:00
2024-11-05 11:03:22 +02:00
WORKDIR /app
2024-11-04 16:45:27 +02:00
2024-11-05 11:03:22 +02:00
COPY . .
2024-11-05 11:09:04 +02:00
RUN npm install -g vite \
2024-11-05 11:10:07 +02:00
&& npm install \
2024-11-05 11:09:04 +02:00
&& npm run build
2024-11-04 16:45:27 +02:00
2024-11-05 11:03:22 +02:00
# PHP stage
FROM php:8.3-fpm-alpine
2024-11-04 16:45:27 +02:00
2024-11-05 11:03:22 +02:00
# Install system packages
RUN apk add --no-cache \
2024-11-04 16:45:27 +02:00
nginx \
supervisor \
curl \
nano \
2024-11-05 11:21:50 +02:00
gettext \
2024-11-05 11:18:58 +02:00
icu-libs \
2024-11-05 11:31:25 +02:00
libzip \
bzip2 \
libxslt \
oniguruma \
sqlite-libs
2024-11-04 16:45:27 +02:00
2024-11-05 11:03:22 +02:00
# Install PHP modules
RUN apk add --no-cache --virtual .build-deps \
2024-11-05 11:12:02 +02:00
icu-dev \
2024-11-04 16:45:27 +02:00
libzip-dev \
2024-11-05 11:03:22 +02:00
freetype-dev \
2024-11-04 16:45:27 +02:00
libpng-dev \
2024-11-05 11:03:22 +02:00
libjpeg-turbo-dev \
2024-11-04 16:45:27 +02:00
libwebp-dev \
2024-11-05 11:03:22 +02:00
bzip2-dev \
curl-dev \
tidyhtml-dev \
2024-11-04 16:45:27 +02:00
libxslt-dev \
2024-11-05 11:03:22 +02:00
oniguruma-dev \
sqlite-dev \
&& docker-php-ext-install -j$(nproc) \
2024-11-04 16:45:27 +02:00
mbstring \
xml \
dom \
zip \
intl \
curl \
calendar \
pdo_sqlite \
2024-11-05 11:03:22 +02:00
bcmath \
&& apk del .build-deps
2024-11-04 16:45:27 +02:00
2024-11-04 18:07:51 +02:00
# Configure php-fpm
2024-11-13 19:08:39 +02:00
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 \
2024-11-04 18:07:51 +02:00
&& 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 \
2024-11-13 19:02:41 +02:00
&& sed -i 's/;clear_env = no/clear_env = no/' /usr/local/etc/php-fpm.d/www.conf \
2024-11-04 18:07:51 +02:00
&& 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 \
2024-11-05 12:05:22 +02:00
&& 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
2024-11-04 17:20:43 +02:00
2024-11-05 11:03:22 +02:00
# Copy configurations
2024-11-04 18:07:51 +02:00
COPY ./docker/conf/etc /etc
2024-11-04 16:45:27 +02:00
2024-11-05 11:03:22 +02:00
# 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
2024-11-05 13:16:49 +02:00
COPY --from=node-builder /app/static /var/www/html/static
2024-11-04 16:45:27 +02:00
2024-11-05 11:03:22 +02:00
# Set permissions
RUN chown -R www-data:www-data /var/www/html
2024-11-04 16:45:27 +02:00
2024-11-05 11:03:22 +02:00
# Create system dirs
RUN mkdir -p /var/run && \
mkdir -p /run/php
2024-11-04 16:45:27 +02:00
2024-11-05 11:03:22 +02:00
# Copy and set entrypoint
2024-11-04 16:45:27 +02:00
COPY ./entrypoint.sh /
2024-11-05 11:03:22 +02:00
CMD ["/bin/sh", "/entrypoint.sh"]
EXPOSE 80