Browse Source

增加docker文件

yucheng 3 years ago
parent
commit
0757c959ae

+ 31 - 0
docker/dockerfiles/adm-front/Dockerfile

@@ -0,0 +1,31 @@
+FROM nginx:1.16.1
+
+MAINTAINER lijie<lijie@persagy.com>
+
+ARG PROGRAM_ID
+ARG PORT_LOCAL
+
+LABEL tier=frontend
+LABEL product=bdtp
+LABEL project=adm-front
+LABEL name=$PROGRAM_ID
+
+#ENV JAVA_OPTS -Dfile.encoding=UTF-8 -Xms300m -Xmx1024m
+ENV TZ Asia/Shanghai
+ENV WORKER_HOME /usr/persagy/saas-web
+ENV CONFIG_PATH /data/SpringCloud
+ENV PROGRAM_NAME $PROGRAM_ID
+
+WORKDIR $WORKER_HOME
+
+RUN sed -i s@/deb.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list \
+    && apt-get update \
+    && apt-get install -y --no-install-recommends tzdata unzip \
+    && apt-get autoclean \
+    && apt-get clean \
+    && rm -rf /var/lib/apt/lists/*
+
+RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' > /etc/timezone
+COPY *.zip $WORKER_HOME/
+RUN unzip *.zip
+RUN rm -rf ./*.zip

+ 59 - 0
docker/k8sfiles/adm-front.yml

@@ -0,0 +1,59 @@
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: adm-front
+  labels:
+    app: adm-front
+spec:
+  selector:
+    app: adm-front
+  ports:
+    - port: 80
+      targetPort: 80
+      name: server-port
+
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: adm-front
+spec:
+  replicas: 1
+  selector:
+    matchLabels:
+      app: adm-front
+  template:
+    metadata:
+      labels:
+        app: adm-front
+    spec:
+      containers:
+        - name: adm-front
+          image: labisenlin.persagy.com/library/adm-front:latest
+          imagePullPolicy: Always
+          ports:
+            - containerPort: 80
+              name: server-port
+          resources:
+            limits:
+              memory: 1Gi
+            requests:
+              memory: 512Mi
+          env:
+            - name: TZ
+              value: Asia/Shanghai
+            - name: SERVER_PORT
+              value: "80"
+          volumeMounts:
+            - name: config
+              mountPath: /etc/nginx/nginx.conf
+              subPath: path/to/nginx.conf.js
+      volumes:
+        - name: config
+          configMap:
+            name: public-config
+            defaultMode: 0777
+            items:
+              - key: nginx.conf
+                path: path/to/nginx.conf.js

+ 80 - 0
docker/k8sfiles/configmap.yml

@@ -0,0 +1,80 @@
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: adm-front
+  namespace: persagy
+  labels:
+    name: adm-front
+data:
+  nginx.conf: |
+    #user tony;
+    worker_processes 4;
+    error_log /var/log/nginx/error.log;
+    pid /run/nginx.pid;
+    worker_rlimit_nofile 100001;
+    # Load dynamic modules. See /usr/share/nginx/README.dynamic.
+    include /usr/share/nginx/modules/*.conf;
+
+    events {
+        worker_connections 1024;
+    }
+
+    http {
+        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
+                          '$status $body_bytes_sent "$http_referer" '
+                          '"$http_user_agent" "$http_x_forwarded_for" "$request_time"';
+
+        access_log  /var/log/nginx/access.log  main;
+
+        sendfile            on;
+        tcp_nopush          on;
+        tcp_nodelay         on;
+        keepalive_timeout   65;
+        types_hash_max_size 2048;
+
+        include             /etc/nginx/mime.types;
+        default_type        application/octet-stream;
+
+        gzip  on;
+        gzip_min_length 1k;
+        gzip_buffers 4 16k;
+        gzip_http_version 1.1;
+        gzip_comp_level 2;
+        gzip_types text/plain application/x-javascript application/css  text/css application/xml text/javascript application/x-httpd-php
+        gzip_vary on;
+
+        server {
+            listen 80 default_server;
+            root /usr/persagy/saas-web;
+
+            # FMS
+            location /admplus {
+                try_files $uri $uri/ /adm-front/index.html;
+            }
+    
+            location @rewrites {
+                rewrite ^(.+)$ /index.html last;
+            }
+
+            location ~* \.(?:ico|css|js|woff|eot|otf|ttf)$ {
+                # Some basic cache-control for static files to be sent to the browser
+                add_header  Access-Control-Allow-Origin *;
+            }
+            location ~index.html
+            {
+                    add_header Cache-Control no-cache;
+            }
+        }
+
+    }
+  vue.config.js: |
+    module.exports = {
+        devServer: {
+            proxy: {
+                '/admplus': {
+                    target: 'http://adm-front:8838',
+                },
+            },
+        },
+    }