Prechádzať zdrojové kódy

feat: 增加部署配置

weijin 4 rokov pred
rodič
commit
6ac54c25b5

+ 9 - 0
Dockerfile

@@ -0,0 +1,9 @@
+FROM node:10-alpine as builder
+WORKDIR /code
+ADD package.json /code
+RUN npm install --registry=https://registry.npm.taobao.org
+ADD . /code
+RUN npm run build
+
+FROM nginx:1.19-alpine
+COPY --from=builder /code/dist/ /var/www/html/dist/

+ 123 - 0
nginx.conf

@@ -0,0 +1,123 @@
+# Generated by nginxconfig.io
+# https://www.digitalocean.com/community/tools/nginx?domains.0.server.redirectSubdomains=false&domains.0.https.https=false&domains.0.php.php=false&domains.0.reverseProxy.reverseProxy=true&domains.0.reverseProxy.path=%2Fapi&domains.0.routing.index=index.html&domains.0.routing.fallbackHtml=true&domains.0.routing.fallbackPhp=false&global.nginx.user=nginx&global.nginx.pid=%2Fvar%2Frun%2Fnginx.pid&global.docker.dockerfile=true&global.tools.modularizedStructure=false&global.tools.symlinkVhost=false&global.app.lang=zhCN
+
+user                 nginx;
+pid                  /var/run/nginx.pid;
+worker_processes     auto;
+worker_rlimit_nofile 65535;
+
+# Load modules
+include              /etc/nginx/modules-enabled/*.conf;
+
+events {
+    multi_accept       on;
+    worker_connections 65535;
+}
+
+http {
+    charset                utf-8;
+    sendfile               on;
+    tcp_nopush             on;
+    tcp_nodelay            on;
+    server_tokens          off;
+    log_not_found          off;
+    types_hash_max_size    2048;
+    types_hash_bucket_size 64;
+    client_max_body_size   16M;
+
+    # MIME
+    include                mime.types;
+    default_type           application/octet-stream;
+
+    # Logging
+    access_log             /var/log/nginx/access.log;
+    error_log              /var/log/nginx/error.log warn;
+
+    # Connection header for WebSocket reverse proxy
+    map $http_upgrade $connection_upgrade {
+        default upgrade;
+        ""      close;
+    }
+
+    # Load configs
+    # include /etc/nginx/conf.d/*.conf;
+
+    # example.com
+    server {
+        listen                             80;
+        listen                             [::]:80;
+        server_name                        bok-manage.seec.seecoder.cn;
+        root                               /var/www/html/dist/;
+
+        # security headers
+        add_header X-Frame-Options         "SAMEORIGIN" always;
+        add_header X-XSS-Protection        "1; mode=block" always;
+        add_header X-Content-Type-Options  "nosniff" always;
+        add_header Referrer-Policy         "no-referrer-when-downgrade" always;
+        add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
+
+        # . files
+        location ~ /\.(?!well-known) {
+            deny all;
+        }
+
+        # index.html fallback
+         location  / {
+           try_files $uri $uri/  /index.html;
+        }
+
+        # reverse proxy
+        location /api {
+            proxy_pass                         http://environment-18-56.seec.svc.cluster.local:8080;
+            proxy_http_version                 1.1;
+            proxy_cache_bypass                 $http_upgrade;
+
+            # Proxy headers
+            proxy_set_header Upgrade           $http_upgrade;
+            proxy_set_header Connection        $connection_upgrade;
+            proxy_set_header Host              $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_set_header X-Forwarded-Host  $host;
+            proxy_set_header X-Forwarded-Port  $server_port;
+
+            # Proxy timeouts
+            proxy_connect_timeout              60s;
+            proxy_send_timeout                 60s;
+            proxy_read_timeout                 60s;
+        }
+
+        # favicon.ico
+        location = /favicon.ico {
+            log_not_found off;
+            access_log    off;
+        }
+
+        # robots.txt
+        location = /robots.txt {
+            log_not_found off;
+            access_log    off;
+        }
+
+        # assets, media
+        location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
+            expires    7d;
+            access_log off;
+        }
+
+        # svg, fonts
+        location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
+            add_header Access-Control-Allow-Origin "*";
+            expires    7d;
+            access_log off;
+        }
+
+        # gzip
+        gzip            on;
+        gzip_vary       on;
+        gzip_proxied    any;
+        gzip_comp_level 6;
+        gzip_types      text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
+    }
+}

+ 1 - 1
src/api/bokfile.js

@@ -6,5 +6,5 @@ import axios from "axios";
  * @returns {Promise<AxiosResponse<any>>}
  */
 export function uploadFile(params, config){
-    return axios.post("/api/api/bok-file", params, config);
+    return axios.post("/api/bok-file", params, config);
 }

+ 2 - 2
src/api/operation_record.js

@@ -6,12 +6,12 @@ import axios from "axios";
  * @returns {Promise<AxiosResponse<any>>}
  */
 export function createRecord(ope_record) {
-    return axios.post("/api/api/ope_record", ope_record);
+    return axios.post("/api/ope_record", ope_record);
 }
 
 
 export function getRecordByQid(qid) {
-    return axios.get("/api/api/ope_record/"+qid,{
+    return axios.get("/api/ope_record/"+qid,{
         params:{
             offset: 0,
             pageSize: 1000,

+ 6 - 6
src/api/question.js

@@ -17,7 +17,7 @@ export function testFunc(name) {
  * @returns {Promise<AxiosResponse<any>>}
  */
 export function getTargetQuestionList(offset, pageSize) {
-    return axios.get("/api/api/pageQuestion", {
+    return axios.get("/api/pageQuestion", {
         params:{
             offset: offset,
             pageSize: pageSize
@@ -31,7 +31,7 @@ export function getTargetQuestionList(offset, pageSize) {
  * @returns {Promise<AxiosResponse<any>>}
  */
 export function requestQuestion(stem, ...items) {
-    return axios.get("/api/api/searchQuestion", {
+    return axios.get("/api/searchQuestion", {
         params: {
             stem: stem,
             tags: items[0],
@@ -50,7 +50,7 @@ export function requestQuestion(stem, ...items) {
  * @returns {Promise<AxiosResponse<any>>}
  */
 export function deleteQuestionById(id) {
-    return axios.delete("/api/api/question/"+id);
+    return axios.delete("/api/question/"+id);
 }
 
 
@@ -60,7 +60,7 @@ export function deleteQuestionById(id) {
  * @returns {Promise<AxiosResponse<any>>}
  */
 export function createQuestion(questionvo) {
-    return axios.post("/api/api/question", questionvo);
+    return axios.post("/api/question", questionvo);
 }
 
 
@@ -70,7 +70,7 @@ export function createQuestion(questionvo) {
  * @returns {Promise<AxiosResponse<any>>}
  */
 export function updateQuestion(questionvo) {
-    return axios.put("/api/api/question/"+questionvo.id, questionvo);
+    return axios.put("/api/question/"+questionvo.id, questionvo);
 }
 
 
@@ -80,7 +80,7 @@ export function updateQuestion(questionvo) {
  * @returns {Promise<AxiosResponse<any>>}
  */
 export function getStateQuestion(states, offset, pageSize) {
-    return axios.get("/api/api/state", {
+    return axios.get("/api/state", {
         params:{
             state: states,
             offset: offset,

+ 2 - 2
src/api/user.js

@@ -7,13 +7,13 @@ import axios from "axios";
  * @returns {Promise<AxiosResponse<any>>}
  */
 export function getUserById(id) {
-    return axios.get("/api/api/user/uid", {params:{
+    return axios.get("/api/user/uid", {params:{
             uid: id
         }});
 }
 
 
 export function getUserInfo(){
-    return axios.get("/api/api/user");
+    return axios.get("/api/user");
 }
 

+ 1 - 1
src/components/BriefQuestionCard.vue

@@ -178,7 +178,7 @@
                     cancelButtonText: '取消',
                     type: 'warning'
                 }).then(() => {
-                    axios.delete("/api/api/question/"+this.questionvo.id).then(() => {
+                    axios.delete("/api/question/"+this.questionvo.id).then(() => {
                             this.$message({
                                 type: 'success',
                                 message: '删除成功!'

+ 1 - 1
src/components/QuestionGroupCreater.vue

@@ -53,7 +53,7 @@
                 question.state = "CHECKING";
                 question.savedUserId = this.$store.state.user.id;
               }
-                axios.post("/api/api/questions", questions)
+                axios.post("/api/questions", questions)
                     .then(res => {
                         console.log(res);
                         this.$notify({

+ 1 - 1
src/views/Bok/Main/Knowledge.vue

@@ -53,7 +53,7 @@ export default {
   },
   mounted() {
     this.knowledgeData = knowledgeData;
-    // axios.get("/api/api/knowledge",{
+    // axios.get("/api/knowledge",{
     //   params:{
     //     "abbreviation_keyPoints": '',
     //   }}).then(res => {

+ 4 - 5
vue.config.js

@@ -8,11 +8,10 @@ module.exports = {
     devServer: {
         proxy: {
             "/api": {
-                target: "http://127.0.0.1:8080",
-                changeOrigin: true,
-                pathRewrite: {
-                    "^/api": ""
-                }
+                // target: "https://bok.seec.seecoder.cn",
+                target: "http://localhost:8080",
+                ws: true,
+                changeOrigin: true
             }
         },
         port: 8000,