Add docker deployment
Some checks failed
build docker image / docker-build (push) Failing after 1m4s

This commit is contained in:
Illya Marchenko 2024-11-05 11:03:22 +02:00
parent 13f81622db
commit 25d043da6b
Signed by: stuzer05
GPG Key ID: A6ABAAA9268F9F4F
3 changed files with 57 additions and 73 deletions

@ -1,62 +1,49 @@
FROM php:8.3-fpm # Build stage
FROM node:18-alpine AS node-builder
# build arguments WORKDIR /app
ARG APP_URL http://localhost
# Update to Debian Trixie COPY . .
RUN cat <<EOF >> /etc/apt/sources.list RUN npm run build
deb http://deb.debian.org/debian trixie main contrib non-free
deb http://deb.debian.org/debian trixie-updates main contrib non-free
deb http://security.debian.org/debian-security trixie-security main contrib non-free
EOF
# Install system dependencies # PHP stage
RUN apt-get update && \ FROM php:8.3-fpm-alpine
apt-get upgrade -y
# Install apps # Install system packages
RUN apt-get install -y --no-install-recommends \ RUN apk add --no-cache \
nginx \ nginx \
rsyslog \
supervisor \ supervisor \
curl \ curl \
wget \
npm \ npm \
nano \ nano \
cmake \ cmake \
gettext \ gettext
unzip
# Install PHP dependencies # Install PHP modules
RUN apt-get install -y --no-install-recommends \ RUN apk add --no-cache --virtual .build-deps \
libzip-dev \ libzip-dev \
libfreetype6=2.12.1+dfsg-5+deb12u3 \ freetype-dev \
libfreetype-dev=2.12.1+dfsg-5+deb12u3 \
libpng-dev \ libpng-dev \
libjpeg62-turbo-dev \ libjpeg-turbo-dev \
libwebp-dev \ libwebp-dev \
libmcrypt-dev \ bzip2-dev \
libbz2-dev \ curl-dev \
libcurl4-openssl-dev \ tidyhtml-dev \
libtidy-dev \
libxslt-dev \ libxslt-dev \
libonig-dev \ oniguruma-dev \
libc-client-dev \ postgresql-dev \
libpq-dev \ sqlite-dev \
libkrb5-dev \ libzip \
libsqlite3-dev \ freetype \
freetds-dev \ libpng \
freetds-bin libjpeg-turbo \
libwebp \
# Cleanup APT bzip2 \
RUN rm -rf \ libxslt \
/var/lib/apt/lists/* \ oniguruma \
/usr/share/man/* \ sqlite-libs \
/usr/share/doc/* \ && docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
/etc/nginx/sites-enabled && docker-php-ext-install -j$(nproc) \
# Install PHP extensions
RUN docker-php-ext-install \
mbstring \ mbstring \
xml \ xml \
dom \ dom \
@ -66,7 +53,8 @@ RUN docker-php-ext-install \
curl \ curl \
calendar \ calendar \
pdo_sqlite \ pdo_sqlite \
bcmath bcmath \
&& apk del .build-deps
# Configure php-fpm # Configure php-fpm
RUN sed -i 's/listen = 127.0.0.1:9000/listen = \/run\/php\/php-fpm.sock/' /usr/local/etc/php-fpm.d/www.conf \ RUN sed -i 's/listen = 127.0.0.1:9000/listen = \/run\/php\/php-fpm.sock/' /usr/local/etc/php-fpm.d/www.conf \
@ -77,27 +65,23 @@ RUN sed -i 's/listen = 127.0.0.1:9000/listen = \/run\/php\/php-fpm.sock/' /usr/l
&& sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 200M/' /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/post_max_size = 8M/post_max_size = 200M/' /usr/local/etc/php/php.ini
# Install Node.js # Copy configurations
RUN npm install -g n && n 18
# Apply configs
COPY ./docker/conf/etc /etc COPY ./docker/conf/etc /etc
# Configure project # Copy built application from node stage
WORKDIR /tmp COPY --from=node-builder /app/dist /var/www/html
COPY --from=node-builder /app/api /var/www/html/api
# Install project # Set permissions
COPY . . RUN chown -R www-data:www-data /var/www/html
RUN npm install \ # Create system dirs
&& npm run build \ RUN mkdir -p /var/run && \
&& chown www-data:www-data . -R \ mkdir -p /run/php
&& rm -r /var/www/html/* \
&& mv /tmp/dist/* /tmp/api /var/www/html \
&& rm -r /tmp/*
WORKDIR /var/www/html
# Copy and set entrypoint
COPY ./entrypoint.sh / COPY ./entrypoint.sh /
CMD ["/bin/bash", "/entrypoint.sh"] CMD ["/bin/sh", "/entrypoint.sh"]
EXPOSE 80

@ -1,20 +1,12 @@
[supervisord] [supervisord]
logfile=/var/log/supervisord.log
logfile_maxbytes=50MB
childlogdir=/var/log
pidfile=/var/run/supervisord.pid
nodaemon=true nodaemon=true
user=root user=root
logfile=/dev/stdout
logfile_maxbytes=0
pidfile=/var/run/supervisord.pid
[supervisorctl] [supervisorctl]
[program:misc-rsyslog]
command=/usr/sbin/rsyslogd -n
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log
[group:webserver] [group:webserver]
programs=webserver-nginx,webserver-phpfpm programs=webserver-nginx,webserver-phpfpm
@ -22,8 +14,16 @@ programs=webserver-nginx,webserver-phpfpm
command=/usr/sbin/nginx -g 'daemon off;' command=/usr/sbin/nginx -g 'daemon off;'
autostart=true autostart=true
autorestart=true autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:webserver-phpfpm] [program:webserver-phpfpm]
command=/usr/local/sbin/php-fpm --nodaemonize --fpm-config /usr/local/etc/php-fpm.d/www.conf command=/usr/local/sbin/php-fpm --nodaemonize --fpm-config /usr/local/etc/php-fpm.d/www.conf
autostart=true autostart=true
autorestart=true autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0