Compare commits

...

2 Commits

Author SHA1 Message Date
a5af277294 Deployment: Fix Docker build failure by adding zip extension and .dockerignore
Some checks failed
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled
Tests / PHP 8.5 (push) Has been cancelled
2026-05-21 04:09:00 +00:00
ffbfde943c Deployment: Upgrade Dockerfile with multi-stage asset building, add Redis service and queue workers 2026-05-21 04:00:30 +00:00
5 changed files with 71 additions and 3 deletions

22
.dockerignore Normal file
View File

@@ -0,0 +1,22 @@
.git
.github
node_modules
vendor
.env
.env.*
!.env.example
bootstrap/cache/*.php
storage/framework/cache/*
storage/framework/sessions/*
storage/framework/views/*
storage/logs/*
database/*.sqlite
public/build
README.md
CHANGELOG.md
TASKS_ROADMAP.md
AGENTS.md
PROGRESS.md
SOP_des.md
SYSTEM_ASSESSMENT_PROPOSALS.md
UI_DESIGN_BRIEF.md

View File

@@ -1,3 +1,12 @@
# Stage 1: Build front-end assets
FROM node:22-alpine AS assets-builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
# Stage 2: Production PHP FPM + Nginx image
FROM php:8.3-fpm-alpine AS base FROM php:8.3-fpm-alpine AS base
RUN apk add --no-cache \ RUN apk add --no-cache \
@@ -10,6 +19,8 @@ RUN apk add --no-cache \
freetype-dev \ freetype-dev \
oniguruma-dev \ oniguruma-dev \
libxml2-dev \ libxml2-dev \
icu-dev \
libzip-dev \
zip \ zip \
unzip \ unzip \
curl curl
@@ -25,7 +36,8 @@ RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
exif \ exif \
gd \ gd \
intl \ intl \
opcache opcache \
zip
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
@@ -36,6 +48,9 @@ RUN composer install --no-dev --no-interaction --no-autoloader --no-scripts --pr
COPY . . COPY . .
# Copy Vite compiled assets
COPY --from=assets-builder /app/public/build ./public/build
RUN composer dump-autoload --optimize --no-dev \ RUN composer dump-autoload --optimize --no-dev \
&& mkdir -p storage/app/private/feedback-attachments \ && mkdir -p storage/app/private/feedback-attachments \
&& mkdir -p storage/framework/{cache,sessions,views} \ && mkdir -p storage/framework/{cache,sessions,views} \

View File

@@ -1,18 +1,35 @@
version: '3.8'
services: services:
app: app:
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
image: minicrm:latest
container_name: minicrm_app
ports: ports:
- "${APP_PORT:-8080}:80" - "${APP_PORT:-8080}:80"
env_file: env_file:
- .env - .env
volumes: volumes:
- ./database/database.sqlite:/var/www/html/database/database.sqlite - ./database:/var/www/html/database
- ./storage/app:/var/www/html/storage/app - ./storage/app:/var/www/html/storage/app
restart: unless-stopped restart: unless-stopped
depends_on:
- redis
healthcheck: healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/admin/login"] test: ["CMD", "curl", "-f", "http://localhost/admin/login"]
interval: 30s interval: 30s
timeout: 5s timeout: 5s
retries: 3 retries: 3
redis:
image: redis:7-alpine
container_name: minicrm_redis
command: redis-server --appendonly yes
volumes:
- redis_data:/data
restart: unless-stopped
volumes:
redis_data:

View File

@@ -3,8 +3,9 @@ set -e
if [ ! -f /var/www/html/database/database.sqlite ]; then if [ ! -f /var/www/html/database/database.sqlite ]; then
touch /var/www/html/database/database.sqlite touch /var/www/html/database/database.sqlite
chown www-data:www-data /var/www/html/database/database.sqlite
fi fi
chown -R www-data:www-data /var/www/html/database
chmod -R 775 /var/www/html/database
if [ -z "$APP_KEY" ]; then if [ -z "$APP_KEY" ]; then
php artisan key:generate --force --no-interaction php artisan key:generate --force --no-interaction

View File

@@ -13,3 +13,16 @@ stdout_logfile_maxbytes=0
command=nginx -g 'daemon off;' command=nginx -g 'daemon off;'
stdout_logfile=/dev/stdout stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0 stdout_logfile_maxbytes=0
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/artisan queue:work --sleep=3 --tries=3 --max-time=3600
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
numprocs=1
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0