Browse Source

feat: cicd

master_tdsql
hxh 1 year ago
parent
commit
37832d69d0
  1. 2
      .env.production
  2. 33
      deploy/Dockerfile
  3. 66
      deploy/dev/app.yaml
  4. 11
      deploy/entryPoint.sh
  5. 67
      deploy/nginx.conf.tmpl

2
.env.production

@ -2,5 +2,5 @@
ENV = 'admin'
# 若依管理系统/生产环境
VUE_APP_BASE_API = '/thinking'
VUE_APP_BASE_API = '/api'
VUE_APP_FAST_BASE_URL = 'http://192.168.1.20:9080/'

33
deploy/Dockerfile

@ -0,0 +1,33 @@
FROM registry.datameta.com:8180/public/node:17.9.1-alpine3.15 as builder
WORKDIR /root
COPY . /root
# RUN npm
ENV NODE_OPTIONS '--openssl-legacy-provider --max-old-space-size=8000'
RUN set -x \
&& sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
&& apk --no-cache add python2 make g++ && npm config set strict-peer-dependencies=false && \
npm install --ignore-optional --registry=http://172.16.32.57:8931/repository/npm-group/ --verbose --legacy-peer-deps && \
npm run build
# RUN yarn config set strict-peer-dependencies false && \
# yarn config set registry http://172.16.32.57:8931/repository/npm-group/ && \
# yarn && \
# yarn run build:pro
# Second stage: minimal runtime environment
FROM registry.datameta.com:8180/public/nginx:1.25-alpine
COPY --from=builder /root/dist /usr/share/nginx/html
WORKDIR /
COPY deploy/nginx.conf.tmpl nginx.conf.tmpl
COPY /deploy/entryPoint.sh entryPoint.sh
RUN chmod +x entryPoint.sh
# expose port
EXPOSE 80
ENTRYPOINT ["sh","/entryPoint.sh"]

66
deploy/dev/app.yaml

@ -0,0 +1,66 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: $APP_NAME
name: $APP_NAME
namespace: $NAME_SPACE
spec:
progressDeadlineSeconds: 600
replicas: 1
selector:
matchLabels:
app: $APP_NAME
template:
metadata:
labels:
app: $APP_NAME
spec:
containers:
- image: $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$NAME_SPACE
imagePullPolicy: Always
name: $APP_NAME-$BUILD_NUMBER
env:
- name: API_SERVER
value: "http://shuili-admin"
- name: NAME_SPACE
value: $NAME_SPACE
readinessProbe:
httpGet:
path: /
port: 80
timeoutSeconds: 10
failureThreshold: 30
periodSeconds: 5
ports:
- containerPort: 80
protocol: TCP
resources:
limits:
cpu: 300m
memory: 600Mi
requests:
cpu: 100m
memory: 100Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
terminationGracePeriodSeconds: 30
---
apiVersion: v1
kind: Service
metadata:
labels:
app: $APP_NAME
name: $APP_NAME
namespace: $NAME_SPACE
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: 80
selector:
app: $APP_NAME
sessionAffinity: None

11
deploy/entryPoint.sh

@ -0,0 +1,11 @@
#!/bin/bash
export NGINX_PORT=${NGINX_PORT:-80}
export NGINX_MAX_BODY_SIZE=${NGINX_MAX_BODY_SIZE:-1024m}
export API_SERVER=${API_SERVER:-http://shuili-admin}
envsubst '${NGINX_PORT},${NGINX_MAX_BODY_SIZE},${API_SERVER}' < nginx.conf.tmpl > /etc/nginx/nginx.conf
nginx -t
nginx -g "daemon off;"

67
deploy/nginx.conf.tmpl

@ -0,0 +1,67 @@
#user nobody;
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
error_log /dev/stdout warn;
access_log /dev/stdout main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
gzip on;
gzip_buffers 4 16k;
gzip_comp_level 6;
gzip_types text/plain application/javascript text/css application/xml text/javascript application/x-httpd-php;
gzip_static on;
gzip_http_version 1.1;
gzip_proxied expired no-cache no-store private auth;
server {
listen ${NGINX_PORT};
listen [::]:${NGINX_PORT};
charset utf-8;
client_max_body_size ${NGINX_MAX_BODY_SIZE};
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location /api {
rewrite ^/api/(.*)$ /$1 break;
proxy_pass ${API_SERVER};
}
}
}
Loading…
Cancel
Save