mirror of
https://github.com/fastapi-practices/fastapi-best-architecture.git
synced 2026-09-21 13:12:24 +00:00
Optimize docker deploy settings and scripts (#486)
This commit is contained in:
@@ -20,7 +20,7 @@ stdout_logfile=/var/log/celery/fba_celery_beat.log
|
||||
|
||||
[program:celery_flower]
|
||||
directory=/fba/backend
|
||||
command=/usr/local/bin/celery -A app.task.celery flower --port=8555 --basic-auth=admin:123456
|
||||
command=/usr/local/bin/celery -A app.task.celery flower --port=8555 --url-prefix=flower --basic-auth=admin:123456
|
||||
user=root
|
||||
autostart=true
|
||||
autorestart=true
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
networks:
|
||||
fba_network:
|
||||
name: fba_network
|
||||
driver: bridge
|
||||
ipam:
|
||||
driver: default
|
||||
config:
|
||||
- subnet: 172.10.10.0/24
|
||||
|
||||
volumes:
|
||||
fba_mysql:
|
||||
name: fba_mysql
|
||||
fba_redis:
|
||||
name: fba_redis
|
||||
fba_static:
|
||||
name: fba_static
|
||||
fba_rabbitmq:
|
||||
name: fba_rabbitmq
|
||||
|
||||
services:
|
||||
fba_server:
|
||||
build:
|
||||
@@ -38,8 +19,7 @@ services:
|
||||
- -c
|
||||
- |
|
||||
wait-for-it -s fba_mysql:3306 -s fba_redis:6379 -t 300
|
||||
mkdir -p /var/log/supervisor/
|
||||
supervisord -c /fba/deploy/backend/supervisor.conf
|
||||
supervisord -c /etc/supervisor/supervisord.conf
|
||||
supervisorctl restart
|
||||
|
||||
fba_mysql:
|
||||
@@ -62,20 +42,20 @@ services:
|
||||
--collation-server=utf8mb4_general_ci
|
||||
--lower_case_table_names=1
|
||||
|
||||
# fba_postgres:
|
||||
# image: postgres:16
|
||||
# ports:
|
||||
# - "${DOCKER_POSTGRES_MAP_PORT:-5432}:5432"
|
||||
# container_name: fba_postgres
|
||||
# restart: always
|
||||
# environment:
|
||||
# POSTGRES_DB: fba
|
||||
# POSTGRES_PASSWORD: 123456
|
||||
# TZ: Asia/Shanghai
|
||||
# volumes:
|
||||
# - fba_postgres:/var/lib/postgresql/data
|
||||
# networks:
|
||||
# - fba_network
|
||||
# fba_postgres:
|
||||
# image: postgres:16
|
||||
# ports:
|
||||
# - "${DOCKER_POSTGRES_MAP_PORT:-5432}:5432"
|
||||
# container_name: fba_postgres
|
||||
# restart: always
|
||||
# environment:
|
||||
# POSTGRES_DB: fba
|
||||
# POSTGRES_PASSWORD: 123456
|
||||
# TZ: Asia/Shanghai
|
||||
# volumes:
|
||||
# - fba_postgres:/var/lib/postgresql/data
|
||||
# networks:
|
||||
# - fba_network
|
||||
|
||||
fba_redis:
|
||||
image: redis:6.2.7
|
||||
@@ -99,33 +79,33 @@ services:
|
||||
depends_on:
|
||||
- fba_server
|
||||
volumes:
|
||||
- ../nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
- ../nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
- fba_static:/www/fba_server/backend/static
|
||||
networks:
|
||||
- fba_network
|
||||
|
||||
# fba_ui:
|
||||
# build:
|
||||
# context: /root/fastapi_best_architecture_ui
|
||||
# dockerfile: Dockerfile
|
||||
# image: fba_ui:latest
|
||||
# ports:
|
||||
# - "80:80"
|
||||
# - "443:443"
|
||||
# container_name: fba_ui
|
||||
# restart: always
|
||||
# depends_on:
|
||||
# - fba_server
|
||||
# command:
|
||||
# - nginx
|
||||
# - -g
|
||||
# - daemon off;
|
||||
# volumes:
|
||||
# # - local_ssl_pem_path:/etc/ssl/xxx.pem
|
||||
# # - local_ssl_key_path:/etc/ssl/xxx.key
|
||||
# - fba_static:/www/fba_server/backend/static
|
||||
# networks:
|
||||
# - fba_network
|
||||
# fba_ui:
|
||||
# build:
|
||||
# context: /root/fastapi_best_architecture_ui
|
||||
# dockerfile: Dockerfile
|
||||
# image: fba_ui:latest
|
||||
# ports:
|
||||
# - "80:80"
|
||||
# - "443:443"
|
||||
# container_name: fba_ui
|
||||
# restart: always
|
||||
# depends_on:
|
||||
# - fba_server
|
||||
# command:
|
||||
# - nginx
|
||||
# - -g
|
||||
# - daemon off;
|
||||
# volumes:
|
||||
# # - local_ssl_pem_path:/etc/ssl/xxx.pem
|
||||
# # - local_ssl_key_path:/etc/ssl/xxx.key
|
||||
# - fba_static:/www/fba_server/backend/static
|
||||
# networks:
|
||||
# - fba_network
|
||||
|
||||
fba_rabbitmq:
|
||||
hostname: fba_rabbitmq
|
||||
@@ -161,6 +141,24 @@ services:
|
||||
- -c
|
||||
- |
|
||||
wait-for-it -s fba_rabbitmq:5672 -t 300
|
||||
mkdir -p /var/log/supervisor/
|
||||
supervisord -c /fba/deploy/backend/supervisor.conf
|
||||
supervisord -c /etc/supervisor/supervisord.conf
|
||||
supervisorctl restart
|
||||
|
||||
networks:
|
||||
fba_network:
|
||||
name: fba_network
|
||||
driver: bridge
|
||||
ipam:
|
||||
driver: default
|
||||
config:
|
||||
- subnet: 172.10.10.0/24
|
||||
|
||||
volumes:
|
||||
fba_mysql:
|
||||
name: fba_mysql
|
||||
fba_redis:
|
||||
name: fba_redis
|
||||
fba_static:
|
||||
name: fba_static
|
||||
fba_rabbitmq:
|
||||
name: fba_rabbitmq
|
||||
|
||||
+32
-39
@@ -1,25 +1,10 @@
|
||||
# For more information on configuration, see:
|
||||
# * Official English Documentation: http://nginx.org/en/docs/
|
||||
# * Official Russian Documentation: http://nginx.org/ru/docs/
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
server_name 127.0.0.1;
|
||||
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
error_log /var/log/nginx/error.log;
|
||||
pid /run/nginx.pid;
|
||||
root /fba;
|
||||
|
||||
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
|
||||
include /usr/share/nginx/modules/*.conf;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
sendfile on;
|
||||
client_max_body_size 5M;
|
||||
client_body_buffer_size 5M;
|
||||
|
||||
@@ -30,29 +15,37 @@ http {
|
||||
|
||||
keepalive_timeout 300;
|
||||
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
server_name 127.0.0.1;
|
||||
location / {
|
||||
proxy_pass http://fba_server:8001;
|
||||
|
||||
root /fba;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_connect_timeout 300s;
|
||||
proxy_send_timeout 300s;
|
||||
proxy_read_timeout 300s;
|
||||
}
|
||||
|
||||
client_max_body_size 10m; # 最大上传文件
|
||||
location /flower/ {
|
||||
proxy_pass http://fba_server:8555;
|
||||
|
||||
location / {
|
||||
proxy_pass http://fba_server:8001;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_connect_timeout 300s;
|
||||
proxy_send_timeout 300s;
|
||||
proxy_read_timeout 300s;
|
||||
proxy_redirect off;
|
||||
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_connect_timeout 300s;
|
||||
proxy_send_timeout 300s;
|
||||
proxy_read_timeout 300s;
|
||||
}
|
||||
# WebSocket 支持
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
|
||||
location /static/ {
|
||||
alias /www/fba_server/backend/static;
|
||||
}
|
||||
location /static {
|
||||
alias /www/fba_server/backend/static;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user