[ chat-bing新版前端 ]


1. default.conf文件-nginx用

server {
    listen       443 ssl;
    #listen  [::]:443;
    server_name  lbwnb.wdnmdnszz.top;

    ssl_certificate      /ssl_key/full_chain.pem;
    ssl_certificate_key  /ssl_key/private.key;

    ssl_session_timeout 5m;   
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers on;

    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html/vue;
        index  index.html index.htm;
    }
    location ^~/api/ {
        proxy_pass https://47.120.55.99:5000/;
    }
    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}

}

server {
    listen 80;
    server_name lbwnb.wdnmdnszz.top;
    rewrite ^(.*)$ https://lbwnb.wdnmdnszz.top permanent;
    root /usr/share/nginx/html/vue;
    index index.html index.htm;
}

2. 前端docker-compose.yml

version: '3'

services:
  nginx:
    image: nginx
    restart: always
    ports:
      - "443:443"
      - "80:80"
    volumes:
      - ./conf/default.conf:/etc/nginx/conf.d/default.conf
      - ./dist/:/usr/share/nginx/html/vue/
      - ./conf/ssl_key/:/ssl_key/
    container_name: nginx

3. dockerfile文件后端部署

FROM python:3

ENV PYTHONUNBUFFERED 1
WORKDIR /usr/src/app

RUN apt-get install default-libmysqlclient-dev -y && \
    ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

COPY requirements.txt ./
RUN pip install --upgrade pip && \
        pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
        pip config set install.trusted-host mirrors.aliyun.com && \
        pip install -Ur requirements.txt && \
        pip install uvicorn[standard]

COPY . .

EXPOSE 5000

CMD ["uvicorn", "main:APP","--host", "0.0.0.0", "--port", "5000", "--reload", "--ssl-certfile", "./ssl_key/full_chain.pem", "--ssl-keyfile", "./ssl_key/private.key"]