Commit 6806f359 authored by Kunkka王辉's avatar Kunkka王辉 😲

feat: 环境配置

parent aecdf45b
# ~/.bashrc: executed by bash(1) for non-login shells.
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
function git-branch-name {
git symbolic-ref --short -q HEAD 2>/dev/null | cut -d"/" -f 3
}
function git-branch-prompt {
local branch=`git-branch-name`
if [ $branch ]; then printf " [%s]" $branch; fi
}
PS1="\u@\h \[\033[0;36m\]\W\[\033[0m\]\[\033[0;32m\]\$(git-branch-prompt)\[\033[0m\] \$ "
function php7()
{
docker run --rm -it --network galaxy-net -v $(pwd):/app galaxy-php:7.4 php "$@"
}
function composer()
{
docker run --rm -it --network galaxy-net -v $(pwd):/app galaxy-php:7.4 composer "$@"
}
# 环境变量env dev,test,test1,test2等区分 # 环境变量env dev,test,test1,test2等区分
ENV=dev ENV=dev
PORT=8118 # 服务宿主机的端口
\ No newline at end of file PORT=80
# 代码目录,含前后端
CODE_DIR=/home/wh/workplace/code_test
\ No newline at end of file
...@@ -5,22 +5,45 @@ services: ...@@ -5,22 +5,45 @@ services:
context: src context: src
dockerfile: Dockerfile-php dockerfile: Dockerfile-php
image: galaxy-php:7.4 image: galaxy-php:7.4
container_name: galaxy-php7.4${ENV:-dev} container_name: galaxy-php7.4-${ENV:-dev}
# environment: volumes:
#目录映射 - ${CODE_DIR}:/var/www
expose: expose:
- 9000 - 9000
networks:
- galaxy-net
nginx: nginx:
build: build:
context: src context: src
dockerfile: Dockerfile-nginx dockerfile: Dockerfile-nginx
# 目录共享 args:
# 指定目录映射 - PHP_HOST=galaxy-php7.4-${ENV:-dev}
# - HOST=nginx-${ENV:-dev}
- DWP_HTTP_PORT=8081
- OLD_CRM_HTTP_PORT=8181
- OLD_CRM_CLIENT_HTTP_PORT=8290
- OLD_CRM_USER_HTTP_PORT=8291
- OLD_CRM_ADMIN_HTTP_PORT=9191
- GALAXY_CRM_API_HTTP_PORT=9101
- GALAXY_FLOW_MICROS_API_HTTP_PORT=9102
- GALAXY_SERVER_SITE_API_HTTP_PORT=9103
- GALAXY_USER_MICROS_API_HTTP_PORT=9104
- GALAXY_PRESALE_MICROS_API_HTTP_PORT=9105
- GALAXY_MICROS_GATEWAY_API_HTTP_PORT=9106
- GALAXY_ENTRY_API_HTTP_PORT=9107
- GALAXY_WORKFLOW_API_HTTP_PORT=9108
- GALAXY_COMMON_SERVER_API_HTTP_PORT=9109
- VUE_USERINFO_PORT=9169
image: galaxy-nginx image: galaxy-nginx
container_name: nginx-test${ENV:-dev} container_name: nginx-${ENV:-dev}
networks:
- galaxy-net
expose: expose:
- 80 - 80
ports: ports:
- "${PORT:-8118}:80" - "${PORT:-8118}:80"
command: ["nginx", "-g","daemon off;"] command: [ "nginx", "-g","daemon off;" ]
\ No newline at end of file networks:
galaxy-net:
name: galaxy-net
driver: bridge
\ No newline at end of file
FROM nginx:latest FROM nginx:latest
## 初始化参数 ## 初始化参数
ARG HOST
ARG PHP_HOST
ARG DWP_HTTP_PORT
ARG OLD_CRM_HTTP_PORT
ARG OLD_CRM_CLIENT_HTTP_PORT
ARG OLD_CRM_USER_HTTP_PORT
ARG OLD_CRM_ADMIN_HTTP_PORT
ARG GALAXY_CRM_API_HTTP_PORT
ARG GALAXY_FLOW_MICROS_API_HTTP_PORT
ARG GALAXY_SERVER_SITE_API_HTTP_PORT
ARG GALAXY_USER_MICROS_API_HTTP_PORT
ARG GALAXY_PRESALE_MICROS_API_HTTP_PORT
ARG GALAXY_MICROS_GATEWAY_API_HTTP_PORT
ARG GALAXY_ENTRY_API_HTTP_PORT
ARG GALAXY_WORKFLOW_API_HTTP_PORT
ARG GALAXY_COMMON_SERVER_API_HTTP_PORT
ARG VUE_USERINFO_PORT
ENTRYPOINT ["/docker-entrypoint.sh"] ENTRYPOINT ["/docker-entrypoint.sh"]
RUN mkdir /etc/nginx/php COPY deploy-hosts.sh /app/deploy-hosts.sh
COPY <<EOF /etc/nginx/php/php7.4.conf RUN chmod +x /app/deploy-hosts.sh && /app/deploy-hosts.sh
location ~ \.php$ {
fastcgi_pass php7.4:9000;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
}
EOF
COPY <<EOF /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
root /app/www;
index index.php index.html index.htm;
location / {
proxy_ignore_client_abort on;
fastcgi_ignore_client_abort on;
try_files \$uri \$uri/ /index.php?\$query_string;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
include /etc/nginx/php/php7.4.conf;
}
EOF
RUN cat /etc/nginx/conf.d/default.conf
EXPOSE 80 EXPOSE 80
STOPSIGNAL SIGQUIT STOPSIGNAL SIGQUIT
......
FROM phpdockerio/php74-cli FROM phpdockerio/php74-cli
# 安装所需的依赖,以及清理临时文件 # apt 国内镜像
COPY <<EOF /etc/apt/sources.list COPY <<EOF /etc/apt/sources.list
deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
...@@ -11,7 +11,7 @@ deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted univers ...@@ -11,7 +11,7 @@ deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted univers
deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
EOF EOF
# 安装扩展
RUN apt-get update && \ RUN apt-get update && \
apt-get -y install php7.4-common php7.4-mysql php7.4-pgsql php7.4-mysqlnd php7.4-gd php7.4-bcmath php7.4-soap php7.4-sqlite3 php7.4-redis php7.4-fpm php7.4-gd php7.4-bcmath php7.4-mongodb php7.4-tidy php7.4-protobuf \ apt-get -y install php7.4-common php7.4-mysql php7.4-pgsql php7.4-mysqlnd php7.4-gd php7.4-bcmath php7.4-soap php7.4-sqlite3 php7.4-redis php7.4-fpm php7.4-gd php7.4-bcmath php7.4-mongodb php7.4-tidy php7.4-protobuf \
php7.4-rdkafka php7.4-tideways php7.4-imap php7.4-imagick php7.4-swoole php7.4-xmlrpc php7.4-intl php-pear php7.4-rdkafka php7.4-tideways php7.4-imap php7.4-imagick php7.4-swoole php7.4-xmlrpc php7.4-intl php-pear
...@@ -28,14 +28,11 @@ RUN sed -i 's/^listen\s=.*sock/listen = 0.0.0.0:9000/g' /etc/php/7.4/fpm/pool.d/ ...@@ -28,14 +28,11 @@ RUN sed -i 's/^listen\s=.*sock/listen = 0.0.0.0:9000/g' /etc/php/7.4/fpm/pool.d/
# 设置工作目录 # 设置工作目录
WORKDIR /app WORKDIR /app
RUN mkdir /app/www RUN mkdir /app/www
COPY <<EOF /app/www/index.php
<?php
phpinfo();
EOF
COPY check.sh /app/
# 检查扩展是否安装完整 # 检查扩展是否安装完整
RUN chmod +x /app/check.sh && /app/check.sh COPY check.sh /app/
RUN chmod +x /app/check.sh && /app/check.sh && rm -f /app/check.sh
# 指定容器启动时执行的命令 # 指定容器启动时执行的命令
CMD ["/usr/sbin/php-fpm7.4","--nodaemonize", "-O"] CMD ["/usr/sbin/php-fpm7.4","--nodaemonize", "-O"]
# 暴露9000端口 # 暴露9000端口
......
#部署的env全部,用来追加到 项目的.env 文件用来支持每个服务之间的调用
#/bin/bash
# 部署所有的应用
mkdir /etc/nginx/php
cat <<EOF >/etc/nginx/php/$PHP_HOST.conf
location ~ \.php$ {
fastcgi_pass $PHP_HOST:9000;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
}
location / {
proxy_ignore_client_abort on;
fastcgi_ignore_client_abort on;
try_files \$uri \$uri/ /index.php?\$query_string;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
EOF
# common-server
cat <<EOF >/etc/nginx/conf.d/common-server.conf
server {
listen $GALAXY_COMMON_SERVER_API_HTTP_PORT;
server_name localhost;
root /app/www/common-server/public;
index index.php index.html;
include /etc/nginx/php/$PHP_HOST.conf;
}
EOF
# crm-admin
cat <<EOF >/etc/nginx/conf.d/crm-admin.conf
server {
listen $OLD_CRM_ADMIN_HTTP_PORT;
server_name localhost;
root /app/www/crm-admin/public;
index index.php index.html;
location ^~ /workflow/ {
proxy_pass http://$HOST:$GALAXY_FLOW_MICROS_API_HTTP_PORT;
}
location ^~ /backend/ {
proxy_pass http://$HOST:$GALAXY_FLOW_MICROS_API_HTTP_PORT;
}
location ^~ /administrator/ {
proxy_pass http://$HOST:$GALAXY_MICROS_GATEWAY_API_HTTP_PORT;
}
location ^~ /presale/ {
proxy_pass http://$HOST:$GALAXY_PRESALE_MICROS_API_HTTP_PORT;
}
location ^~ /intelligentWriting/ {
#待部署
proxy_pass http://middle-platform.galaxy-immi.com:8319/intelligentWriting/;
}
location ^~ /business/ {
proxy_pass http://$HOST:$GALAXY_SERVER_SITE_API_HTTP_PORT;
}
location ^~ /biz-platform/ {
# 待部署
proxy_pass http://middle-platform.galaxy-immi.com:8315/biz-platform/;
}
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
location /{
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
try_files \$uri \$uri/ /index.html;
}
}
EOF
# crm-client
cat <<EOF >/etc/nginx/conf.d/crm-client.conf
server {
listen $OLD_CRM_CLIENT_HTTP_PORT;
server_name localhost;
root /app/www/crm-client;
index index.php index.html;
location ^~ /backend/ {
proxy_pass http://$HOST:$GALAXY_FLOW_MICROS_API_HTTP_PORT;
proxy_cache_valid 404 500 503 502 200 304 10s;
}
location ^~ /administrator/ {
proxy_pass http://$HOST:$GALAXY_MICROS_GATEWAY_API_HTTP_PORT;
proxy_cache_valid 404 500 503 502 200 304 10s;
}
location ^~ /client-web/ {
#待部署
proxy_pass http://middle-platform.galaxy-immi.com:8308;
#获取客户端真实IP
proxy_set_header X-Real-PORT \$remote_port;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$remote_addr;
}
location ^~ /business/ {
proxy_pass http://$HOST:$GALAXY_SERVER_SITE_API_HTTP_PORT/business/;
}
location ^~ /newsystem/ {
proxy_pass http://middle-platform.galaxy-immi.com:8291/;
}
#禁止访问的文件或目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
location /{
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
try_files \$uri \$uri/ /index.html;
}
}
EOF
# crm-userinfo
cat <<EOF >/etc/nginx/conf.d/crm-userinfo.conf
server {
listen $OLD_CRM_USER_HTTP_PORT;
server_name localhost;
root /app/www/user-information-system;
index index.php index.html;
location ^~ /backend/ {
proxy_pass http://$HOST:$GALAXY_FLOW_MICROS_API_HTTP_PORT;
proxy_cache_valid 404 500 503 502 200 304 10s;
}
location ^~ /administrator/ {
proxy_pass http://$HOST:$GALAXY_MICROS_GATEWAY_API_HTTP_PORT;
proxy_cache_valid 404 500 503 502 200 304 10s;
}
location ^~ /client-web/ {
#待部署
proxy_pass http://middle-platform.galaxy-immi.com:8308;
#获取客户端真实IP
proxy_set_header X-Real-PORT \$remote_port;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$remote_addr;
}
location ^~ /business/ {
proxy_pass http://$HOST:$GALAXY_SERVER_SITE_API_HTTP_PORT/business/;
}
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
}
EOF
## dwp
cat <<EOF >/etc/nginx/conf.d/dwp.conf
server {
listen $DWP_HTTP_PORT;
server_name localhost;
root /app/www/dwp/main;
index index.php index.html;
location / {
root /app/www/dwp/main;
index index.html;
try_files \$uri \$uri/ /index.html;
}
location ^~ /subapp {
alias /app/www/dwp/subapp;
try_files \$uri \$uri/ /index.html;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers *;
add_header Access-Control-Allow-Methods *;
}
location ^~ /subapp/userInfo/ {
proxy_pass http://$HOST:$VUE_USERINFO_PORT/;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header Host \$host;
proxy_set_header X-Real-Ip \$remote_addr;
proxy_set_header X-Ngnix-Proxy true;
}
location ^~ /api/ {
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header Host \$host;
proxy_set_header X-Real-Ip \$remote_addr;
proxy_set_header X-Ngnix-Proxy true;
proxy_pass http://$HOST:$GALAXY_CRM_API_HTTP_PORT/;
}
location ^~ /crm/api/ {
proxy_pass http://$HOST:$GALAXY_MICROS_GATEWAY_API_HTTP_PORT/;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Real-Ip \$remote_addr;
proxy_set_header X-Ngnix-Proxy true;
}
location ^~ /serversitemicrosApi/ {
proxy_pass http://$HOST:$GALAXY_SERVER_SITE_API_HTTP_PORT/;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Real-Ip \$remote_addr;
proxy_set_header X-Ngnix-Proxy true;
}
location ^~ /smarterApi/ {
# 待部署
proxy_pass https://test.smartwhale.galaxy-immi.com/api/;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Real-Ip \$remote_addr;
proxy_set_header X-Ngnix-Proxy true;
}
location ^~ /earlyWarning/smartWhale/api/ {
proxy_pass http://$HOST:$GALAXY_CRM_API_HTTP_PORT/;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Real-Ip \$remote_addr;
proxy_set_header X-Ngnix-Proxy true;
}
location ^~ /earlyWarning/ {
#待部署
proxy_pass https://test.earlywarning.galaxy-immi.com/api/;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Real-Ip \$remote_addr;
proxy_set_header X-Ngnix-Proxy true;
}
location ~ .*\.(js|css)?$
{
root /app/www/dwp/main;
}
#禁止访问的文件或目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
}
EOF
# entry
cat <<EOF >/etc/nginx/conf.d/entry.conf
server {
listen $GALAXY_ENTRY_API_HTTP_PORT;
server_name localhost;
root /app/www/entry/public;
index index.php index.html;
include /etc/nginx/php/$PHP_HOST.conf;
}
EOF
# flow-mircos
cat <<EOF >/etc/nginx/conf.d/flow-micros.conf
server {
listen $GALAXY_FLOW_MICROS_API_HTTP_PORT;
server_name localhost;
root /app/www/flow-micros/public;
index index.php index.html;
include /etc/nginx/php/$PHP_HOST.conf;
}
EOF
# galaxy-crm
cat <<EOF >/etc/nginx/conf.d/galaxy-crm.conf
server {
listen $GALAXY_CRM_API_HTTP_PORT;
server_name localhost;
root /app/www/galaxy-crm/public;
index index.php index.html;
include /etc/nginx/php/$PHP_HOST.conf;
}
EOF
# galaxy-workflow
cat <<EOF >/etc/nginx/conf.d/galaxy-workflow.conf
server {
listen $GALAXY_WORKFLOW_API_HTTP_PORT;
server_name localhost;
root /app/www/galaxy-workflow/public;
index index.php index.html;
include /etc/nginx/php/$PHP_HOST.conf;
}
EOF
# micros-gateway
cat <<EOF >/etc/nginx/conf.d/micros-gateway.conf
server {
listen $GALAXY_MICROS_GATEWAY_API_HTTP_PORT;
server_name localhost;
root /app/www/micros-gateway/public;
index index.php index.html;
include /etc/nginx/php/$PHP_HOST.conf;
}
EOF
# old-crm
cat <<EOF >/etc/nginx/conf.d/old-crm.conf
server {
listen $OLD_CRM_HTTP_PORT;
server_name localhost;
root /app/www/CRM;
index index.php index.html;
location ^~ /backend/ {
proxy_pass http://$HOST:$GALAXY_FLOW_MICROS_API_HTTP_PORT;
proxy_cache_valid 404 500 503 502 200 304 10s;
}
location ^~ /administrator/ {
proxy_pass http://$HOST:$GALAXY_MICROS_GATEWAY_API_HTTP_PORT;
proxy_cache_valid 404 500 503 502 200 304 10s;
}
location ^~ /client-web/ {
#待部署
proxy_pass http://middle-platform.galaxy-immi.com:8308;
#获取客户端真实IP
proxy_set_header X-Real-PORT \$remote_port;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$remote_addr;
}
location ^~ /business/ {
proxy_pass http://$HOST:$GALAXY_SERVER_SITE_API_HTTP_PORT/business/;
}
location ^~ /consultant/ {
# 待部署
proxy_pass http://test.consultant.galaxy-immi.com;
}
location ^~ /presale/ {
proxy_pass http://$HOST:$GALAXY_PRESALE_MICROS_API_HTTP_PORT;
}
}
EOF
# presale-micros
cat <<EOF >/etc/nginx/conf.d/presale-micros.conf
server {
listen $GALAXY_PRESALE_MICROS_API_HTTP_PORT;
server_name localhost;
root /app/www/presale-micros/public;
index index.php index.html;
include /etc/nginx/php/$PHP_HOST.conf;
}
EOF
# server-site
cat <<EOF >/etc/nginx/conf.d/server-site.conf
server {
listen $GALAXY_SERVER_SITE_API_HTTP_PORT;
server_name localhost;
root /app/www/server-site/public;
index index.php index.html;
include /etc/nginx/php/$PHP_HOST.conf;
}
EOF
# user-micros
cat <<EOF >/etc/nginx/conf.d/user-micros.conf
server {
listen $GALAXY_USER_MICROS_API_HTTP_PORT;
server_name localhost;
root /app/www/user-micros/public;
index index.php index.html;
include /etc/nginx/php/$PHP_HOST.conf;
}
EOF
# vue-userinfo
cat <<EOF >/etc/nginx/conf.d/vue-userinfo.conf
server {
listen $VUE_USERINFO_PORT;
server_name localhost;
root /app/www/dwp/subapp/userInfo;
index index.php index.html;
location ^~ /api/ {
proxy_pass http://$HOST:$GALAXY_CRM_API_HTTP_PORT/;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header Host \$host;
proxy_set_header X-Real-Ip \$remote_addr;
proxy_set_header X-Ngnix-Proxy true;
}
}
EOF
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment