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

@ -1,20 +1,12 @@
[supervisord]
logfile=/var/log/supervisord.log
logfile_maxbytes=50MB
childlogdir=/var/log
pidfile=/var/run/supervisord.pid
nodaemon=true
user=root
logfile=/dev/stdout
logfile_maxbytes=0
pidfile=/var/run/supervisord.pid
[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]
programs=webserver-nginx,webserver-phpfpm
@ -22,8 +14,16 @@ programs=webserver-nginx,webserver-phpfpm
command=/usr/sbin/nginx -g 'daemon off;'
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:webserver-phpfpm]
command=/usr/local/sbin/php-fpm --nodaemonize --fpm-config /usr/local/etc/php-fpm.d/www.conf
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0