OneBot: Leantime 改造版源码(BOM/Univer 表格/AI 接管/品牌替换等)
This commit is contained in:
131
.docker/Dockerfile
Normal file
131
.docker/Dockerfile
Normal file
@@ -0,0 +1,131 @@
|
||||
# Build stage
|
||||
FROM --platform=$TARGETPLATFORM php:8.3-fpm-alpine AS builder
|
||||
|
||||
# Add QEMU for cross-platform builds
|
||||
COPY --from=tonistiigi/binfmt:latest /usr/bin/qemu-* /usr/bin/
|
||||
|
||||
# Install build dependencies
|
||||
RUN apk add --no-cache --virtual .build-deps \
|
||||
$PHPIZE_DEPS \
|
||||
gcc \
|
||||
g++ \
|
||||
openssl-dev \
|
||||
make \
|
||||
libxml2-dev \
|
||||
oniguruma-dev \
|
||||
openldap-dev \
|
||||
zstd-dev \
|
||||
libzip-dev \
|
||||
freetype-dev \
|
||||
libpng-dev \
|
||||
libjpeg-turbo-dev \
|
||||
postgresql-dev
|
||||
|
||||
# Set cross-compilation flags if needed
|
||||
ARG TARGETPLATFORM
|
||||
RUN case "${TARGETPLATFORM}" in \
|
||||
linux/arm64*) export CFLAGS='-march=armv8-a' CXXFLAGS='-march=armv8-a' ;; \
|
||||
esac
|
||||
|
||||
# Install and configure PHP extensions
|
||||
RUN set -ex; \
|
||||
# Configure extensions
|
||||
docker-php-ext-configure gd --with-freetype --with-jpeg; \
|
||||
# Install extensions one by one to prevent memory issues
|
||||
docker-php-ext-install mysqli && \
|
||||
docker-php-ext-install pdo_mysql && \
|
||||
docker-php-ext-install pdo_pgsql && \
|
||||
docker-php-ext-install bcmath && \
|
||||
docker-php-ext-install mbstring && \
|
||||
docker-php-ext-install exif && \
|
||||
docker-php-ext-install pcntl && \
|
||||
docker-php-ext-install opcache && \
|
||||
docker-php-ext-install ldap && \
|
||||
docker-php-ext-install zip && \
|
||||
pecl install redis && docker-php-ext-enable redis && \
|
||||
docker-php-ext-install gd && \
|
||||
rm -rf /tmp/* /var/cache/apk/*
|
||||
|
||||
|
||||
|
||||
# Production stage
|
||||
FROM --platform=$TARGETPLATFORM php:8.3-fpm-alpine
|
||||
|
||||
# Add production dependencies
|
||||
RUN apk add --no-cache \
|
||||
tini \
|
||||
nginx \
|
||||
mysql-client \
|
||||
openssl \
|
||||
supervisor \
|
||||
freetype \
|
||||
libpng \
|
||||
zstd-libs \
|
||||
libjpeg-turbo \
|
||||
libzip \
|
||||
openldap \
|
||||
libpq \
|
||||
icu-libs && \
|
||||
rm -rf /var/cache/apk/* /tmp/*
|
||||
|
||||
# Copy built extensions from builder
|
||||
COPY --from=builder /usr/local/lib/php/extensions/ /usr/local/lib/php/extensions/
|
||||
COPY --from=builder /usr/local/etc/php/conf.d/ /usr/local/etc/php/conf.d/
|
||||
|
||||
# Add non-root user
|
||||
ARG PUID=1000
|
||||
ARG PGID=1000
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /var/www/html
|
||||
|
||||
# Install Leantime
|
||||
ARG LEAN_VERSION
|
||||
RUN set -ex; \
|
||||
curl -fsSL --retry 3 https://github.com/Leantime/leantime/releases/download/v${LEAN_VERSION}/Leantime-v${LEAN_VERSION}.tar.gz -o leantime.tar.gz && \
|
||||
tar xzf leantime.tar.gz --strip-components 1 && \
|
||||
rm leantime.tar.gz && \
|
||||
chown -R www-data:www-data .
|
||||
|
||||
# Set Permissions
|
||||
RUN set -ex; \
|
||||
# Modify existing www-data user/group
|
||||
deluser www-data; \
|
||||
addgroup -g ${PGID} www-data; \
|
||||
adduser -u ${PUID} -G www-data -h /home/www-data -s /bin/sh -D www-data; \
|
||||
# Create required directories
|
||||
mkdir -p /var/www/html/userfiles \
|
||||
/var/www/html/public/userfiles \
|
||||
/var/www/html/bootstrap/cache \
|
||||
/var/www/html/storage/logs \
|
||||
/var/www/html/storage/framework/cache \
|
||||
/var/www/html/storage/framework/sessions \
|
||||
/var/www/html/storage/framework/views \
|
||||
/var/www/html/app/Plugins \
|
||||
/run /var/log/nginx /var/lib/nginx; \
|
||||
chown -R www-data:www-data /var/www/html /run /var/log/nginx /var/lib/nginx && \
|
||||
chmod 775 /var/www/html/userfiles \
|
||||
/var/www/html/public/userfiles \
|
||||
/var/www/html/bootstrap/cache \
|
||||
/var/www/html/storage/logs \
|
||||
/var/www/html/storage/framework/cache \
|
||||
/var/www/html/storage/framework/sessions \
|
||||
/var/www/html/storage/framework/views \
|
||||
/var/www/html/app/Plugins;
|
||||
|
||||
# Copy configuration files
|
||||
COPY config/custom.ini /usr/local/etc/php/conf.d/
|
||||
COPY config/nginx.conf /etc/nginx/nginx.conf
|
||||
COPY config/php-fpm.conf /usr/local/etc/php-fpm.d/www.conf
|
||||
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||
COPY --chmod=0755 start.sh /start.sh
|
||||
|
||||
# Switch to non-root user
|
||||
USER www-data
|
||||
|
||||
# Add healthcheck
|
||||
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
|
||||
CMD curl -f http://localhost:8080 || exit 1
|
||||
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["/sbin/tini", "--", "/start.sh"]
|
||||
23
.docker/config/custom.ini
Normal file
23
.docker/config/custom.ini
Normal file
@@ -0,0 +1,23 @@
|
||||
memory_limit = 1G
|
||||
max_execution_time = 300
|
||||
opcache.enable = 1
|
||||
opcache.jit=1255
|
||||
opcache.jit_buffer_size=128M
|
||||
|
||||
; Optimized opcache settings
|
||||
opcache.memory_consumption=128
|
||||
opcache.interned_strings_buffer=8
|
||||
opcache.max_accelerated_files=4000
|
||||
opcache.revalidate_freq=60
|
||||
opcache.fast_shutdown=1
|
||||
|
||||
; Upload settings
|
||||
upload_max_filesize = 100M
|
||||
post_max_size = 100M
|
||||
|
||||
; Session handling
|
||||
session.gc_maxlifetime = 28800
|
||||
|
||||
; Error Handline
|
||||
display_errors = off
|
||||
log_errors = on
|
||||
86
.docker/config/nginx.conf
Normal file
86
.docker/config/nginx.conf
Normal file
@@ -0,0 +1,86 @@
|
||||
user www-data www-data;
|
||||
worker_processes auto;
|
||||
pid /run/nginx.pid;
|
||||
error_log /dev/stderr info;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
access_log /dev/stdout;
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
client_max_body_size 100M;
|
||||
|
||||
# SSL
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
|
||||
|
||||
# Security headers
|
||||
add_header X-Frame-Options "DENY" always;
|
||||
add_header X-XSS-Protection "1; mode=block; report=/xss-report" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header Referrer-Policy "no-referrer-when-downgrade" always;
|
||||
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
|
||||
server {
|
||||
listen 8080;
|
||||
server_name _;
|
||||
root /var/www/html/public;
|
||||
index index.php;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
fastcgi_read_timeout 300;
|
||||
}
|
||||
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
|
||||
# additional config
|
||||
# favicon.ico
|
||||
location = /favicon.ico {
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
# robots.txt
|
||||
location = /robots.txt {
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location ^~ /dist/ {
|
||||
expires 7d;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
# Enable gzip compression
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_proxied expired no-cache no-store private auth;
|
||||
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/javascript;
|
||||
gzip_disable "MSIE [1-6]\.";
|
||||
}
|
||||
}
|
||||
28
.docker/config/php-fpm.conf
Normal file
28
.docker/config/php-fpm.conf
Normal file
@@ -0,0 +1,28 @@
|
||||
[global]
|
||||
error_log = /proc/self/fd/2
|
||||
daemonize = no
|
||||
|
||||
[www]
|
||||
user = www-data
|
||||
group = www-data
|
||||
|
||||
listen = 127.0.0.1:9000
|
||||
listen.owner = www-data
|
||||
listen.group = www-data
|
||||
listen.mode = 0660
|
||||
|
||||
pm = dynamic
|
||||
pm.max_children = 50
|
||||
pm.start_servers = 5
|
||||
pm.min_spare_servers = 5
|
||||
pm.max_spare_servers = 35
|
||||
pm.max_requests = 500
|
||||
|
||||
clear_env = no
|
||||
|
||||
catch_workers_output = yes
|
||||
decorate_workers_output = no
|
||||
|
||||
chdir = /var/www/html
|
||||
php_admin_value[error_log] = /proc/self/fd/2
|
||||
php_admin_flag[log_errors] = on
|
||||
32
.docker/config/supervisord.conf
Normal file
32
.docker/config/supervisord.conf
Normal file
@@ -0,0 +1,32 @@
|
||||
[supervisord]
|
||||
nodaemon=true
|
||||
logfile=/dev/stdout
|
||||
loglevel=info
|
||||
logfile_maxbytes=0
|
||||
pidfile=/run/supervisord.pid
|
||||
|
||||
[program:php-fpm]
|
||||
command=php-fpm -F
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
autostart=true
|
||||
autorestart=true
|
||||
priority=5
|
||||
startretries=10
|
||||
|
||||
[program:nginx]
|
||||
command=nginx -g 'daemon off;'
|
||||
autostart=true
|
||||
autorestart=true
|
||||
priority=10
|
||||
|
||||
[program:scheduler]
|
||||
command=php /var/www/html/bin/leantime schedule:work
|
||||
autostart=true
|
||||
autorestart=true
|
||||
user=www-data
|
||||
stdout_logfile=/dev/fd/1
|
||||
stdout_logfile_maxbytes=0
|
||||
redirect_stderr=true
|
||||
64
.docker/docker-compose.yml
Normal file
64
.docker/docker-compose.yml
Normal file
@@ -0,0 +1,64 @@
|
||||
version: '3.3'
|
||||
|
||||
services:
|
||||
leantime_db:
|
||||
image: mysql:8.4
|
||||
container_name: mysql_leantime
|
||||
volumes:
|
||||
- db_data:/var/lib/mysql
|
||||
restart: unless-stopped
|
||||
env_file: ./.env # Environment file with settings
|
||||
networks:
|
||||
- leantime-net
|
||||
command: --character-set-server=UTF8MB4 --collation-server=UTF8MB4_unicode_ci
|
||||
healthcheck:
|
||||
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
|
||||
leantime:
|
||||
image: leantime/leantime:3.4.12
|
||||
restart: unless-stopped
|
||||
env_file: ./.env # Environment file with settings
|
||||
# Add security options
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
# Add capabilities
|
||||
cap_add:
|
||||
# - CAP_NET_BIND_SERVICE
|
||||
- CAP_CHOWN
|
||||
- CAP_SETGID
|
||||
- CAP_SETUID
|
||||
ports:
|
||||
- "${LEAN_PORT:-8080}:8080"
|
||||
networks:
|
||||
- leantime-net
|
||||
volumes:
|
||||
- public_userfiles:/var/www/html/public/userfiles # Volume to store public files, logo etc
|
||||
- userfiles:/var/www/html/userfiles # Original volume name for compatibility
|
||||
- plugins:/var/www/html/app/Plugins # Plugin storage
|
||||
- logs:/var/www/html/storage/logs # Log storage
|
||||
depends_on:
|
||||
leantime_db:
|
||||
condition: service_healthy
|
||||
|
||||
# Add a helper container for volume permissions
|
||||
# Run via docker compose --profile mysql_helper up -d
|
||||
mysql_helper:
|
||||
image: mysql:8.4
|
||||
command: chown -R mysql:mysql /var/lib/mysql
|
||||
volumes:
|
||||
- db_data:/var/lib/mysql
|
||||
user: root
|
||||
profiles: [ "helper" ]
|
||||
|
||||
volumes:
|
||||
db_data:
|
||||
userfiles: # New volume for public files
|
||||
public_userfiles:
|
||||
plugins:
|
||||
logs:
|
||||
|
||||
networks:
|
||||
leantime-net:
|
||||
51
.docker/start.sh
Normal file
51
.docker/start.sh
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [[ -n "${LEAN_DB_PASSWORD_FILE}" ]]; then
|
||||
LEAN_DB_PASSWORD=$(cat "${LEAN_DB_PASSWORD_FILE}")
|
||||
export LEAN_DB_PASSWORD
|
||||
fi
|
||||
|
||||
if [[ -n "${LEAN_EMAIL_SMTP_PASSWORD_FILE}" ]]; then
|
||||
LEAN_EMAIL_SMTP_PASSWORD=$(cat "${LEAN_EMAIL_SMTP_PASSWORD_FILE}")
|
||||
export LEAN_EMAIL_SMTP_PASSWORD
|
||||
fi
|
||||
|
||||
if [[ -n "${LEAN_S3_SECRET_FILE}" ]]; then
|
||||
LEAN_S3_SECRET=$(cat "${LEAN_S3_SECRET_FILE}")
|
||||
export LEAN_S3_SECRET
|
||||
fi
|
||||
|
||||
if [[ -n "${LEAN_SESSION_PASSWORD_FILE}" ]]; then
|
||||
LEAN_SESSION_PASSWORD=$(cat "${LEAN_SESSION_PASSWORD_FILE}")
|
||||
export LEAN_SESSION_PASSWORD
|
||||
fi
|
||||
|
||||
if [[ -n "${LEAN_REDIS_PASSWORD_FILE}" ]]; then
|
||||
LEAN_REDIS_PASSWORD=$(cat "${LEAN_REDIS_PASSWORD_FILE}")
|
||||
export LEAN_REDIS_PASSWORD
|
||||
fi
|
||||
|
||||
if [[ -n "${LEAN_DB_HOST_FILE}" ]]; then
|
||||
LEAN_DB_HOST=$(cat "${LEAN_DB_HOST_FILE}")
|
||||
export LEAN_DB_HOST
|
||||
fi
|
||||
|
||||
if [[ -n "${LEAN_DB_DATABASE_FILE}" ]]; then
|
||||
LEAN_DB_DATABASE=$(cat "${LEAN_DB_DATABASE_FILE}")
|
||||
export LEAN_DB_DATABASE
|
||||
fi
|
||||
|
||||
if [[ -n "${LEAN_DB_USER_FILE}" ]]; then
|
||||
LEAN_DB_USER=$(cat "${LEAN_DB_USER_FILE}")
|
||||
export LEAN_DB_USER
|
||||
fi
|
||||
|
||||
if [[ -n "${LEAN_EMAIL_SMTP_USERNAME_FILE}" ]]; then
|
||||
LEAN_EMAIL_SMTP_USERNAME=$(cat "${LEAN_EMAIL_SMTP_USERNAME_FILE}")
|
||||
export LEAN_EMAIL_SMTP_USERNAME
|
||||
fi
|
||||
|
||||
# Ensure supervisord can write its pid file
|
||||
mkdir -p /run
|
||||
|
||||
/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
|
||||
Reference in New Issue
Block a user