kphcdr 11 ماه پیش
کامیت
b59048aaa2
10فایلهای تغییر یافته به همراه279 افزوده شده و 0 حذف شده
  1. 6 0
      .env
  2. 1 0
      .gitignore
  3. 31 0
      config/mysql/mysqld.cnf
  4. 61 0
      config/nginx/conf.d/vhost.conf
  5. 42 0
      config/nginx/nginx.conf
  6. 65 0
      config/php/Dockerfile
  7. 1 0
      config/php/php.ini
  8. 63 0
      docker-compose.yml
  9. 6 0
      env.example
  10. 3 0
      www/server/public/index.php

+ 6 - 0
.env

@@ -0,0 +1,6 @@
+# 容器名称
+ABBREVIATION=kphcdr
+# 统一前缀端口 1-5
+NUMBER=1
+
+MYSQL_PASSWORD=root

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+.idea

+ 31 - 0
config/mysql/mysqld.cnf

@@ -0,0 +1,31 @@
+# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+
+#
+# The MySQL  Server configuration file.
+#
+# For explanations see
+# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
+
+[mysqld]
+pid-file	= /var/run/mysqld/mysqld.pid
+socket		= /var/run/mysqld/mysqld.sock
+datadir		= /var/lib/mysql
+log-error	= /var/log/mysql/error.log
+# By default we only accept connections from localhost
+#bind-address	= 127.0.0.1
+# Disabling symbolic-links is recommended to prevent assorted security risks
+symbolic-links=0
+max_connections=1000

+ 61 - 0
config/nginx/conf.d/vhost.conf

@@ -0,0 +1,61 @@
+server {
+    listen 80;
+    access_log /logs/access_nginx.log;
+    error_log /logs/error_nginx.log;
+    client_max_body_size 5M;
+    root   /www/server/public;
+    index  index.html index.htm index.php;
+
+    location / {
+        if (!-e $request_filename)
+        {
+            rewrite ^/(.*)$ /index.php?s=$1 last;
+            break;
+        }
+    }
+
+    location @router {
+        rewrite ^.*$ /index.html last;
+    }
+    location ~ /.*\.php/ {
+        rewrite ^(.*?/?)(.*\.php)(.*)$ /$2?s=$3 last;
+        break;
+    }
+
+    location ^~ /platform {
+        try_files $uri $uri/ @router;
+        alias /www/platform/dist/;
+        index  index.html index.htm;
+    }
+
+    location ^~ /agent_admin {
+        try_files $uri $uri/ @router;
+        alias /www/agent_admin/dist/;
+        index  index.html index.htm;
+    }
+
+    location ^~ /admin {
+        try_files $uri $uri/ @router;
+        alias /www/admin/dist/;
+        index  index.html index.htm;
+    }
+
+
+    error_page   500 502 503 504  /50x.html;
+    location = /50x.html {
+        root   /var/www/html;
+    }
+
+    location ~ \.php$ {
+        fastcgi_pass   php:9000;
+        fastcgi_index  index.php;
+        fastcgi_param  SCRIPT_FILENAME  /www/server/public$fastcgi_script_name;
+        include        fastcgi_params;
+    }
+    location = /favicon.ico {
+            log_not_found off;
+            access_log off;
+        }
+}
+
+

+ 42 - 0
config/nginx/nginx.conf

@@ -0,0 +1,42 @@
+
+user  root;
+worker_processes  2;
+
+error_log  /var/log/nginx/error.log warn;
+pid        /var/run/nginx.pid;
+
+
+events {
+    worker_connections  1024;
+}
+
+
+http {
+    include       /etc/nginx/mime.types;
+    default_type  application/octet-stream;
+
+    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
+                      '$status $body_bytes_sent "$http_referer" '
+                      '"$http_user_agent" "$http_x_forwarded_for"';
+
+    access_log  /var/log/nginx/access.log  main;
+
+    sendfile        on;
+    tcp_nopush     on;
+
+    keepalive_timeout  65;
+
+    #gzip  on;
+
+    server {
+        listen       80;
+        location / {
+               return 404;
+         }
+    }
+
+    include /etc/nginx/conf.d/company/*.conf;
+    include /etc/nginx/conf.d/my/*.conf;
+    include /etc/nginx/conf.d/product/*.conf;
+    include /etc/nginx/conf.d/project/*.conf;
+}

+ 65 - 0
config/php/Dockerfile

@@ -0,0 +1,65 @@
+FROM php:8.0-fpm
+
+MAINTAINER xs
+
+ENV TZ="Asia/Shanghai"
+
+RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
+
+#RUN cp /etc/apt/sources.list /etc/apt/sources.list.bak && \
+#    echo "deb http://mirrors.aliyu  n.com/debian/ buster main non-free contrib" >/etc/apt/sources.list && \
+#    echo "deb-src http://mirrors.aliyun.com/debian/ buster main non-free contrib" >>/etc/apt/sources.list && \
+#    echo "deb http://mirrors.aliyun.com/debian-security buster/updates main" >>/etc/apt/sources.list && \
+#    echo "deb-src http://mirrors.aliyun.com/debian-security buster/updates main" >>/etc/apt/sources.list && \
+#    echo "deb http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib" >>/etc/apt/sources.list && \
+#    echo "deb-src http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib" >>/etc/apt/sources.list && \
+#    echo "deb http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib" >>/etc/apt/sources.list && \
+#    echo "deb-src http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib" >>/etc/apt/sources.list
+
+# Utils
+RUN apt-get update && \
+    apt-get install -y libssl-dev libaio-dev procps wget vim zip unzip git net-tools dnsutils && \
+    apt-get clean
+
+# Composer
+RUN curl -sS https://getcomposer.org/installer | php && \
+    mv composer.phar /usr/local/bin/composer && \
+    composer self-update --clean-backups && \
+    composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
+
+# Core Libs
+RUN echo "Installing Core Libs..." && \
+    #gd
+    apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev && \
+    docker-php-ext-configure gd --with-freetype --with-jpeg && \
+    docker-php-ext-install -j$(nproc) gd && \
+
+    # bcmath
+    docker-php-ext-install bcmath && \
+
+    # sockets
+    docker-php-ext-install sockets && \
+
+    # MySQL extension
+    docker-php-ext-install mysqli && \
+    docker-php-ext-install pdo_mysql && \
+
+    # Redis
+    pecl install redis && \
+    docker-php-ext-enable redis && \
+
+     # swoole
+    pecl install swoole && \
+    docker-php-ext-enable swoole
+
+# ZIP
+RUN apt-get install -y libzip-dev && \
+    docker-php-ext-install -j$(nproc) zip
+
+## Crontab
+RUN apt-get install -y cron
+
+# Expose port 9000
+EXPOSE 9000
+
+WORKDIR /

+ 1 - 0
config/php/php.ini

@@ -0,0 +1 @@
+upload_max_filesize = 5M

+ 63 - 0
docker-compose.yml

@@ -0,0 +1,63 @@
+version: '3'
+
+networks:
+  flvshop:
+    driver: bridge
+
+services:
+  nginx:
+    container_name: ${ABBREVIATION}-nginx
+    image:  docker.io/nginx:1.23.0
+    restart: always
+    depends_on:
+      - "php"
+    volumes:
+      - ./www:/www
+      - ./config/nginx/conf.d:/etc/nginx/conf.d
+      - ./log/nginx/logs:/logs
+    networks:
+      - flvshop
+    ports:
+      - "${NUMBER}080:80"
+
+  php:
+    build:
+      context: ./config/php
+      args:
+        PHP_VERSION: php:8.0-fpm
+        TZ: "Asia/Shanghai"
+    restart: always
+    container_name: ${ABBREVIATION}-php-fpm
+    working_dir: /www/server
+    volumes:
+      - ./www:/www
+      - ./config/php/php.ini:/usr/local/etc/php/php.ini
+    networks:
+      - flvshop
+
+  mysql:
+    container_name: ${ABBREVIATION}-mysql
+    image:  docker.io/mysql:5.7.29 #X86架构
+    restart: always
+    platform: linux/amd64  #osx系统才需要
+    ports:
+      - "${NUMBER}3306:3306"   
+    volumes:
+      - ./data/mysql5.7.29/lib:/var/lib/mysql
+      - ./config/mysql/mysqld.cnf:/etc/mysql/my.cnf
+    environment:
+      MYSQL_ROOT_PASSWORD: ${MYSQL_PASSWORD}
+      TZ: "Asia/Shanghai"
+    networks:
+      - flvshop
+
+  redis:
+    container_name: ${ABBREVIATION}-redis
+    image:  docker.io/redis:6.2.7
+    restart: always
+    volumes:
+      - ./data/redis:/data
+    networks:
+      - flvshop
+    ports:
+      - "${NUMBER}6379:6379"

+ 6 - 0
env.example

@@ -0,0 +1,6 @@
+# 容器名称
+ABBREVIATION=kphcdr
+# 统一前缀端口 1-5
+NUMBER=1
+
+MYSQL_PASSWORD=root

+ 3 - 0
www/server/public/index.php

@@ -0,0 +1,3 @@
+<?php
+
+phpinfo();