5 changed files with 178 additions and 1 deletions
@ -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"] |
@ -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 |
@ -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;" |
@ -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…
Reference in new issue