Upload 5 files
Browse filesFiles changed (5)
- Dockerfile+56-2
- dmtask.shAdded+13
- entrypoint.shAdded+67
- nginx.confAdded+24
- supervisord.confAdded+47
12FROM netcccyun/dnsmgrEXPOSE 80811234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556FROM alpine:3.19# Install all dependenciesRUN apk add --no-cache \mariadb mariadb-client \nginx \php82 php82-fpm \php82-pdo php82-pdo_mysql php82-mysqli \php82-mbstring php82-curl php82-openssl php82-json \php82-tokenizer php82-xml php82-ctype php82-bcmath \php82-fileinfo php82-gd php82-zip php82-phar \php82-session php82-dom php82-simplexml php82-xmlwriter \php82-iconv php82-posix php82-pcntl \supervisor \curl unzip \&& ln -sf /usr/bin/php82 /usr/bin/php# Download dnsmgr releaseRUN curl -fSL -o /tmp/dnsmgr.zip https://github.com/netcccyun/dnsmgr/releases/download/2.18/dnsmgr_2.18.zip \&& unzip -q /tmp/dnsmgr.zip -d /tmp/dnsmgr \&& mkdir -p /app/www \&& cp -r /tmp/dnsmgr/* /app/www/ \&& cp -r /tmp/dnsmgr/.??* /app/www/ \&& rm -rf /tmp/dnsmgr.zip /tmp/dnsmgr# Configure nginxCOPY nginx.conf /etc/nginx/http.d/default.conf# Configure php-fpmRUN sed -i 's/;daemonize\s*=\s*yes/daemonize = no/' /etc/php82/php-fpm.conf \&& sed -i 's/listen\s*=\s*127.0.0.1:9000/listen = \/run\/php\/php8.2-fpm.sock/' /etc/php82/php-fpm.d/www.conf \&& sed -i 's/;listen.owner\s*=\s*nobody/listen.owner = nginx/' /etc/php82/php-fpm.d/www.conf \&& sed -i 's/;listen.group\s*=\s*nobody/listen.group = nginx/' /etc/php82/php-fpm.d/www.conf \&& mkdir -p /run/php# Configure supervisordCOPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf# Copy entrypoint scriptCOPY entrypoint.sh /entrypoint.shRUN chmod +x /entrypoint.sh# Copy dmtask wrapperCOPY dmtask.sh /app/www/dmtask.shRUN chmod +x /app/www/dmtask.sh# Create required directoriesRUN mkdir -p /run/nginx /run/mysqld /var/lib/mysql /var/log/mariadb /var/log/supervisor \&& chown -R mysql:mysql /var/lib/mysql /var/log/mariadb /run/mysqld \&& chown -R nginx:nginx /app/www \&& chown -R nginx:nginx /run/phpEXPOSE 8081ENTRYPOINT ["/entrypoint.sh"]CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
12345678910111213#!/bin/shif [ ! -f /app/www/.env ]; then sleep 60 exit 0fi
mysql -u dnsmgr -p123456 dnsmgr -e "SELECT 1 FROM dnsmgr_config LIMIT 1" >/dev/null 2>&1if [ $? -ne 0 ]; then sleep 10 exit 1fi
exec /usr/bin/php /app/www/think dmtask12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667#!/bin/shset -e
DB_ROOT_PASSWORD="123456"DB_NAME="dnsmgr"DB_USER="dnsmgr"DB_PASSWORD="123456"DB_PORT=3306DB_PREFIX="dnsmgr_"INIT_FLAG="/var/lib/mysql/.initialized"
if [ ! -f "$INIT_FLAG" ]; then echo "=== Initializing MariaDB ==="
mysql_install_db --datadir=/var/lib/mysql --user=mysql >/dev/null 2>&1
mysqld --datadir=/var/lib/mysql --user=mysql --skip-networking & MYSQL_PID=$!
for i in $(seq 1 30); do if mysql -u root --socket=/run/mysqld/mysqld.sock -e "SELECT 1" >/dev/null 2>&1; then break fi sleep 1 done
mysql -u root --socket=/run/mysqld/mysqld.sock <<EOSQLFLUSH PRIVILEGES;ALTER USER 'root'@'localhost' IDENTIFIED BY '${DB_ROOT_PASSWORD}';CREATE DATABASE IF NOT EXISTS \`${DB_NAME}\` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;CREATE USER IF NOT EXISTS '${DB_USER}'@'localhost' IDENTIFIED BY '${DB_PASSWORD}';GRANT ALL PRIVILEGES ON \`${DB_NAME}\`.* TO '${DB_USER}'@'localhost';FLUSH PRIVILEGES;EOSQL
kill $MYSQL_PID 2>/dev/null wait $MYSQL_PID 2>/dev/null || true
touch "$INIT_FLAG" echo "=== MariaDB initialized ==="fi
if [ ! -f /app/www/.env ]; then cat > /app/www/.env <<EOFAPP_DEBUG = false
[APP]DEFAULT_TIMEZONE = Asia/Shanghai
[DATABASE]TYPE = mysqlHOSTNAME = 127.0.0.1DATABASE = ${DB_NAME}USERNAME = ${DB_USER}PASSWORD = ${DB_PASSWORD}HOSTPORT = ${DB_PORT}CHARSET = utf8mb4PREFIX = ${DB_PREFIX}DEBUG = false
[LANG]default_lang = zh-cnEOF echo "=== .env written ==="fi
exec "$@"123456789101112131415161718192021222324server { listen 8081; server_name _; root /app/www/public; index index.php index.html;
access_log /dev/stdout; error_log /dev/stderr;
location / { try_files $uri $uri/ /index.php?$query_string; }
location ~ \.php$ { fastcgi_pass unix:/run/php/php8.2-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
location ~ /\.(ht|env|git) { deny all; }}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647[supervisord]nodaemon=truelogfile=/dev/stdoutlogfile_maxbytes=0pidfile=/run/supervisord.pid
[program:mariadb]command=/usr/bin/mysqld --datadir=/var/lib/mysql --user=mysqlpriority=10autostart=trueautorestart=truestdout_logfile=/dev/stdoutstdout_logfile_maxbytes=0stderr_logfile=/dev/stderrstderr_logfile_maxbytes=0
[program:php-fpm]command=/usr/sbin/php-fpm82 --nodaemonize --fpm-config /etc/php82/php-fpm.confpriority=20autostart=trueautorestart=truestdout_logfile=/dev/stdoutstdout_logfile_maxbytes=0stderr_logfile=/dev/stderrstderr_logfile_maxbytes=0
[program:nginx]command=/usr/sbin/nginx -g "daemon off;"priority=30autostart=trueautorestart=truestdout_logfile=/dev/stdoutstdout_logfile_maxbytes=0stderr_logfile=/dev/stderrstderr_logfile_maxbytes=0
[program:dmtask]command=/bin/sh /app/www/dmtask.shpriority=40autostart=trueautorestart=truestartsecs=5startretries=3stdout_logfile=/dev/stdoutstdout_logfile_maxbytes=0stderr_logfile=/dev/stderrstderr_logfile_maxbytes=0Dockerfile+56-2
dmtask.shAdded+13
entrypoint.shAdded+67
nginx.confAdded+24
supervisord.confAdded+47