Fixes
This commit is contained in:
@@ -5,6 +5,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
|
group: docker-build-dev
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
name: "Build - Docker Image"
|
name: "Build - Docker Image - PROD"
|
||||||
run-name: ${{ gitea.actor }} is runs ci pipeline
|
run-name: ${{ gitea.actor }} is runs ci pipeline
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
|
||||||
- "[0-9]+.[0-9]+.[0-9]+"
|
concurrency:
|
||||||
|
group: docker-build-dev
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish:
|
publish:
|
||||||
@@ -15,12 +17,6 @@ jobs:
|
|||||||
image: catthehacker/ubuntu:act-latest
|
image: catthehacker/ubuntu:act-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- run: |
|
|
||||||
echo $RELEASE_VERSION
|
|
||||||
echo '${{ env.RELEASE_VERSION }}' > ./public/version.txt
|
|
||||||
|
|
||||||
- uses: docker/setup-buildx-action@v1
|
- uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
@@ -36,7 +32,7 @@ jobs:
|
|||||||
push: true
|
push: true
|
||||||
labels: |
|
labels: |
|
||||||
org.steelants.image.traffic.version=${{ env.release_version }}
|
org.steelants.image.traffic.version=${{ env.release_version }}
|
||||||
tags: git.steelants.cz/steelants/docker_php_base:${{ env.release_version }}, git.steelants.cz/steelants/docker_php_base:latest
|
tags: git.steelants.cz/steelants/docker_php_base:latest
|
||||||
|
|
||||||
# ✅ Notifikace při úspěšném deploymentu
|
# ✅ Notifikace při úspěšném deploymentu
|
||||||
- name: Discord Webhook Success
|
- name: Discord Webhook Success
|
||||||
@@ -62,4 +58,4 @@ jobs:
|
|||||||
Repo: ${{ github.repository }}
|
Repo: ${{ github.repository }}
|
||||||
Branch: ${{ github.ref_name }}
|
Branch: ${{ github.ref_name }}
|
||||||
Commit: ${{ github.sha }}
|
Commit: ${{ github.sha }}
|
||||||
Version: ${{ env.release_version }}
|
Version: ${{ env.release_version }}
|
||||||
+31
-62
@@ -1,23 +1,18 @@
|
|||||||
# Use PHP with Apache as the base image
|
# Use PHP with Apache as the base image
|
||||||
FROM php:8.4-apache
|
FROM php:8.4-apache
|
||||||
|
|
||||||
# Timezone
|
# Environment
|
||||||
ENV TZ="Europe/Prague"
|
ENV TZ="Europe/Prague" \
|
||||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
APACHE_DOCUMENT_ROOT="/var/www/html/public" \
|
||||||
RUN printf '[Date]\ndate.timezone="%s"\n', $TZ > /usr/local/etc/php/conf.d/tzone.ini
|
PHP_INI_FILE="$PHP_INI_DIR/php.ini" \
|
||||||
|
PHP_OPCACHE_VALIDATE_TIMESTAMPS="1" \
|
||||||
# OPcache
|
|
||||||
ENV PHP_OPCACHE_VALIDATE_TIMESTAMPS="1" \
|
|
||||||
PHP_OPCACHE_MAX_ACCELERATED_FILES="10000" \
|
PHP_OPCACHE_MAX_ACCELERATED_FILES="10000" \
|
||||||
PHP_OPCACHE_MEMORY_CONSUMPTION="192" \
|
PHP_OPCACHE_MEMORY_CONSUMPTION="192" \
|
||||||
PHP_OPCACHE_MAX_WASTED_PERCENTAGE="10"
|
PHP_OPCACHE_MAX_WASTED_PERCENTAGE="10" \
|
||||||
|
COMPOSER_ALLOW_SUPERUSER=1
|
||||||
|
|
||||||
# PHP
|
# Timezone
|
||||||
RUN export PHP_INI_DIR="$PHP_INI_DIR/php.ini"
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \
|
|
||||||
sed -i "s|memory_limit = 128M|memory_limit = 256M |g" "$PHP_INI_DIR/php.ini" && \
|
|
||||||
sed -i "s|upload_max_filesize = 2M|upload_max_filesize = 100M |g" "$PHP_INI_DIR/php.ini" && \
|
|
||||||
sed -i "s|post_max_size = 8M|post_max_size = 100M |g" "$PHP_INI_DIR/php.ini"
|
|
||||||
|
|
||||||
# Install Additional System Dependencies
|
# Install Additional System Dependencies
|
||||||
RUN rm -f /etc/apt/apt.conf.d/docker-clean
|
RUN rm -f /etc/apt/apt.conf.d/docker-clean
|
||||||
@@ -35,11 +30,15 @@ RUN --mount=type=cache,target=/var/cache/apt \
|
|||||||
postgresql-client \
|
postgresql-client \
|
||||||
imagemagick \
|
imagemagick \
|
||||||
libmagickwand-dev \
|
libmagickwand-dev \
|
||||||
|
librsvg2-2 \
|
||||||
|
librsvg2-dev \
|
||||||
|
librsvg2-bin \
|
||||||
supervisor && \
|
supervisor && \
|
||||||
git clone https://github.com/Imagick/imagick --depth 1 /tmp/imagick && \
|
git clone https://github.com/Imagick/imagick --depth 1 /tmp/imagick && \
|
||||||
cd /tmp/imagick && \
|
cd /tmp/imagick && \
|
||||||
phpize && \
|
phpize && \
|
||||||
./configure && \
|
./configure --with-rsvg && \
|
||||||
|
ldconfig && \
|
||||||
make && \
|
make && \
|
||||||
make install && \
|
make install && \
|
||||||
apt-get autoremove && \
|
apt-get autoremove && \
|
||||||
@@ -55,8 +54,16 @@ RUN a2enmod rewrite
|
|||||||
RUN docker-php-ext-install pdo_mysql pgsql pdo_pgsql zip opcache pcntl sockets
|
RUN docker-php-ext-install pdo_mysql pgsql pdo_pgsql zip opcache pcntl sockets
|
||||||
RUN docker-php-ext-enable imagick
|
RUN docker-php-ext-enable imagick
|
||||||
|
|
||||||
|
# PHP
|
||||||
|
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_FILE" && \
|
||||||
|
sed -i "s|memory_limit = 128M|memory_limit = 256M |g" "$PHP_INI_FILE" && \
|
||||||
|
sed -i "s|upload_max_filesize = 2M|upload_max_filesize = 100M |g" "$PHP_INI_FILE" && \
|
||||||
|
sed -i "s|post_max_size = 8M|post_max_size = 100M |g" "$PHP_INI_FILE" && \
|
||||||
|
printf '[Date]\ndate.timezone="%s"\n', $TZ > "$PHP_INI_DIR/conf.d/tzone.ini"
|
||||||
|
|
||||||
#OPCACHE
|
#OPCACHE
|
||||||
RUN echo '[opcache]\n\
|
RUN echo '\n\
|
||||||
|
[opcache]\n\
|
||||||
opcache.enable=1\n\
|
opcache.enable=1\n\
|
||||||
opcache.revalidate_freq=0\n\
|
opcache.revalidate_freq=0\n\
|
||||||
opcache.validate_timestamps=${PHP_OPCACHE_VALIDATE_TIMESTAMPS}\n\
|
opcache.validate_timestamps=${PHP_OPCACHE_VALIDATE_TIMESTAMPS}\n\
|
||||||
@@ -67,56 +74,18 @@ opcache.interned_strings_buffer=16\n\
|
|||||||
opcache.fast_shutdown=1' >> "$PHP_INI_DIR/conf.d/opcache.ini"
|
opcache.fast_shutdown=1' >> "$PHP_INI_DIR/conf.d/opcache.ini"
|
||||||
|
|
||||||
#SUPERVISORD
|
#SUPERVISORD
|
||||||
|
RUN mkdir -p /var/log/supervisor
|
||||||
COPY supervisor/* /etc/supervisor
|
COPY supervisor/* /etc/supervisor
|
||||||
|
|
||||||
# Configure Apache DocumentRoot to point to Laravel's public directory
|
# Setup Crone
|
||||||
# and update Apache configuration files
|
RUN mkdir -p /var/log/cron && \
|
||||||
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
|
echo "* * * * * www-data cd /var/www/html && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1" >> /etc/crontab
|
||||||
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf && \
|
|
||||||
sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
|
|
||||||
|
|
||||||
# Install composer # bun
|
# Install composer # bun
|
||||||
ENV COMPOSER_ALLOW_SUPERUSER=1
|
|
||||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||||
RUN chown -R www-data:www-data /var/www/html && \
|
|
||||||
chmod -R 775 /var/www/html
|
|
||||||
|
|
||||||
# Patch Docker Entrypoint
|
# Configure Apache DocumentRoot to point to Laravel's public directory
|
||||||
RUN sed -i 's/^exec /printenv > \/etc\/environment\n\nexec /' /usr/local/bin/apache2-foreground && \
|
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf && \
|
||||||
|
sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf && \
|
||||||
|
sed -i 's/^exec /printenv > \/etc\/environment\n\nexec /' /usr/local/bin/apache2-foreground && \
|
||||||
sed -i 's/^exec /service cron start\n\nexec /' /usr/local/bin/apache2-foreground
|
sed -i 's/^exec /service cron start\n\nexec /' /usr/local/bin/apache2-foreground
|
||||||
|
|
||||||
# Install project composer dependencies
|
|
||||||
USER www-data
|
|
||||||
COPY --chown=www-data:www-data composer.* /var/www/html
|
|
||||||
RUN --mount=type=cache,target=/root/.composer/vendor \
|
|
||||||
composer install --prefer-dist --no-dev -o --no-scripts
|
|
||||||
|
|
||||||
# Install project npm dependencies
|
|
||||||
COPY --chown=www-data:www-data package*.json /var/www/html
|
|
||||||
RUN npm install
|
|
||||||
|
|
||||||
# Copy the application code
|
|
||||||
COPY --chown=www-data:www-data . /var/www/html
|
|
||||||
RUN --mount=type=cache,target=/root/.composer/vendor \
|
|
||||||
composer install --prefer-dist --no-dev -o
|
|
||||||
RUN npm run build
|
|
||||||
USER root
|
|
||||||
|
|
||||||
# Fix Permissions
|
|
||||||
RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache && \
|
|
||||||
chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache
|
|
||||||
|
|
||||||
#Start Container
|
|
||||||
RUN chmod +x /var/www/html/start.sh
|
|
||||||
CMD ["/var/www/html/start.sh"]
|
|
||||||
|
|
||||||
# Set the working directory
|
|
||||||
VOLUME /var/www/html/storage/app
|
|
||||||
|
|
||||||
RUN mkdir -p /config
|
|
||||||
VOLUME /config
|
|
||||||
|
|
||||||
EXPOSE 8899
|
|
||||||
|
|
||||||
# Start Apache
|
|
||||||
WORKDIR /var/www/html/
|
|
||||||
|
|||||||
@@ -1,91 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# ----- LOGGING FUNCTIONS -----
|
|
||||||
log_info() { echo -e "\033[1;34m[INFO]\033[0m $1"; }
|
|
||||||
log_warn() { echo -e "\033[1;33m[WARN]\033[0m $1"; }
|
|
||||||
log_error() { echo -e "\033[1;31m[ERROR]\033[0m $1"; }
|
|
||||||
|
|
||||||
# ----- START -----
|
|
||||||
log_info "Starting Laravel container setup"
|
|
||||||
|
|
||||||
init=false
|
|
||||||
|
|
||||||
# Initialize environment
|
|
||||||
if [ ! -f /config/.env ]; then
|
|
||||||
log_info "Creating .env from example"
|
|
||||||
cp .env.example .env
|
|
||||||
# Ensure APP_KEY exists
|
|
||||||
if ! grep -q "^APP_KEY=base64" .env; then
|
|
||||||
log_info "Generating application key"
|
|
||||||
php artisan key:generate
|
|
||||||
fi
|
|
||||||
cp .env /config/.env
|
|
||||||
init=true
|
|
||||||
else
|
|
||||||
log_info "Using existing /config/.env"
|
|
||||||
cp /config/.env .env
|
|
||||||
fi
|
|
||||||
|
|
||||||
# SQLite database initialization
|
|
||||||
if { grep -iq "^DB_CONNECTION=sqlite" .env && [ "$DB_CONNECTION" = "sqlite" ]; } || [ "$DEPLOY_ENV" = "sqlite" ]; then
|
|
||||||
if [ ! -f database/database.sqlite ]; then
|
|
||||||
log_info "Creating empty SQLite database"
|
|
||||||
touch database/database.sqlite
|
|
||||||
init=true
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Composer dependencies
|
|
||||||
if [ "$init" = "true" ] || [ "$(echo "$APP_DEBUG" | tr '[:upper:]' '[:lower:]')" = "true" ]; then
|
|
||||||
log_info "Initial setup nebo debug mód - instalace Composeru s dev závislostmi"
|
|
||||||
composer install --prefer-dist --optimize-autoloader
|
|
||||||
else
|
|
||||||
log_info "Produkční instalace - Composer bez dev závislostí"
|
|
||||||
composer install --prefer-dist --no-dev --optimize-autoloader
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check Laravel module dependencies
|
|
||||||
log_info "Checking Laravel module dependencies..."
|
|
||||||
if php artisan app:check-module-dependencies; then
|
|
||||||
log_info "All module dependencies satisfied"
|
|
||||||
else
|
|
||||||
log_error "Missing module dependencies - exiting"
|
|
||||||
if [ "$init" != "true" ] && [ "$(echo "$APP_DEBUG" | tr '[:upper:]' '[:lower:]')" != "true" ]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Link storage and seed database if first init
|
|
||||||
if [ "$init" = true ]; then
|
|
||||||
log_info "Linking storage directory"
|
|
||||||
php artisan storage:link
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Migrate database
|
|
||||||
log_info "Running database migrations"
|
|
||||||
php artisan migrate --force --no-interaction
|
|
||||||
|
|
||||||
# Clear Laravel caches
|
|
||||||
log_info "Clearing Laravel caches"
|
|
||||||
php artisan cache:clear
|
|
||||||
php artisan config:clear
|
|
||||||
php artisan route:clear
|
|
||||||
php artisan view:clear
|
|
||||||
|
|
||||||
if [ "$(echo "$APP_DEBUG" | tr '[:upper:]' '[:lower:]')" = "false" ]; then
|
|
||||||
php artisan config:cache
|
|
||||||
php artisan route:cache
|
|
||||||
php artisan view:cache
|
|
||||||
sed -ri -e 's!opcache.enable=1!opcache.enable=0!g' "${PHP_INI_DIR}/conf.d/opcache.ini"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#supervisord
|
|
||||||
/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
|
|
||||||
|
|
||||||
#Start Socket Server
|
|
||||||
php artisan reverb:start --host=0.0.0.0 --port=8899 --no-interaction --debug &
|
|
||||||
|
|
||||||
# Start Apache
|
|
||||||
log_info "Starting Apache server"
|
|
||||||
exec apache2-foreground
|
|
||||||
@@ -1,38 +1,20 @@
|
|||||||
[program:laravel-worker-default]
|
[program:queue-default]
|
||||||
process_name=%(program_name)s_%(process_num)02d
|
command=/usr/local/bin/php /var/www/html/artisan queue:work --queue=default,importstatistics
|
||||||
command=php /var/www/html/artisan queue:work --queue=default,importstatistics
|
user=www-data
|
||||||
autostart=true
|
autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
stopasgroup=true
|
stdout_logfile=/var/log/supervisor/queue-default.log
|
||||||
killasgroup=true
|
|
||||||
numprocs=1
|
|
||||||
redirect_stderr=true
|
|
||||||
stdout_logfile=/var/www/html/storage/logs/worker.log
|
|
||||||
stopwaitsecs=3600
|
|
||||||
stdout_logfile_maxbytes=5MB
|
|
||||||
|
|
||||||
[program:laravel-worker-statistics]
|
[program:queue-statistics]
|
||||||
process_name=%(program_name)s_%(process_num)02d
|
command=/usr/local/bin/php /var/www/html/artisan queue:work --queue=statistics
|
||||||
command=php /var/www/html/artisan queue:work --queue=statisticss
|
user=www-data
|
||||||
autostart=true
|
autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
stopasgroup=true
|
stdout_logfile=/var/log/supervisor/queue-statistics.log
|
||||||
killasgroup=true
|
|
||||||
numprocs=1
|
|
||||||
redirect_stderr=true
|
|
||||||
stdout_logfile=/var/www/html/storage/logs/worker.log
|
|
||||||
stopwaitsecs=3600
|
|
||||||
stdout_logfile_maxbytes=5MB
|
|
||||||
|
|
||||||
[program:laravel-worker-detections]
|
[program:queue-detections]
|
||||||
process_name=%(program_name)s_%(process_num)02d
|
command=/usr/local/bin/php /var/www/html/artisan queue:work --queue=detections
|
||||||
command=php /var/www/html/artisan queue:work --queue=detectionss
|
user=www-data
|
||||||
autostart=true
|
autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
stopasgroup=true
|
stdout_logfile=/var/log/supervisor/queue-detections.log
|
||||||
killasgroup=true
|
|
||||||
numprocs=1
|
|
||||||
redirect_stderr=true
|
|
||||||
stdout_logfile=/var/www/html/storage/logs/worker.log
|
|
||||||
stopwaitsecs=3600
|
|
||||||
stdout_logfile_maxbytes=5MB
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
[program:laravel-scheduler]
|
|
||||||
process_name=%(program_name)s_%(process_num)02d
|
|
||||||
command=php /var/www/html/artisan artisan schedule:run
|
|
||||||
autostart=true
|
|
||||||
autorestart=true
|
|
||||||
stopasgroup=true
|
|
||||||
killasgroup=true
|
|
||||||
numprocs=1
|
|
||||||
redirect_stderr=true
|
|
||||||
stdout_logfile=/var/www/html/storage/logs/worker.log
|
|
||||||
stopwaitsecs=3600
|
|
||||||
stdout_logfile_maxbytes=5MB
|
|
||||||
@@ -1,18 +1,6 @@
|
|||||||
[supervisord]
|
[supervisord]
|
||||||
logfile=/etc/supervisor/logs/supervisord.log ; main log file; default $CWD/supervisord.log
|
nodaemon=true
|
||||||
logfile_maxbytes=5MB ; max main logfile bytes b4 rotation; default 50MB
|
logfile=/var/log/supervisor/supervisord.log
|
||||||
logfile_backups=10 ; # of main logfile backups; 0 means none, default 10
|
|
||||||
loglevel=info ; log level; default info; others: debug,warn,trace
|
|
||||||
pidfile=/tmp/supervisord.pid ; supervisord pidfile; default supervisord.pid
|
|
||||||
nodaemon=false ; start in foreground if true; default false
|
|
||||||
minfds=1024 ; min. avail startup file descriptors; default 1024
|
|
||||||
minprocs=200 ; min. avail process descriptors;default 200
|
|
||||||
|
|
||||||
[rpcinterface:supervisor]
|
|
||||||
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
|
||||||
|
|
||||||
[supervisorctl]
|
|
||||||
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
|
|
||||||
|
|
||||||
[include]
|
[include]
|
||||||
files = /etc/supervisor/conf.d/*.conf
|
files = /etc/supervisor/conf.d/*.conf
|
||||||
Reference in New Issue
Block a user