From ad8f790e18327e5ba75ffd337aaa01bf6d5586a5 Mon Sep 17 00:00:00 2001 From: 13078417792 <397201698@qq.com> Date: Sat, 5 Jun 2021 22:26:15 +0800 Subject: [PATCH] demo ci --- .dockerignore | 1 + .drone.yml | 109 +++++++-------------------------------------- Dockerfile | 16 +++++++ docker-compose.yml | 9 ++-- http.sh | 5 +++ nginx.conf | 12 +++-- 6 files changed, 50 insertions(+), 102 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 http.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..b512c09d --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/.drone.yml b/.drone.yml index 343198b2..a9563cd2 100644 --- a/.drone.yml +++ b/.drone.yml @@ -7,99 +7,24 @@ trigger: steps: - - name: net - image: praqma/network-multitool - commands: - - ifconfig - - ping -c 2 bucket || true - - - name: upload - image: plugins/s3 + - name: build-docker-image + image: plugins/docker settings: - endpoint: http://bucket:9000 - access_key: - from_secret: bucket_access_key - secret_key: - from_secret: bucket_secret_key - bucket: dronetest - path_style: true - source: src/* - target: / + username: + from_secret: docker_reg_username + password: + from_secret: docker_reg_password + repo: docker.zcj.plus/drone-ci/fe + tags: latest + registry: https://docker.zcj.plus - - - - # - name: rebuild - # image: drillster/drone-volume-cache - # volumes: - # - name: modules - # path: /cache - # settings: - # rebuild: true - # mount: - # - .env - - # - name: restore-modules - # image: drillster/drone-volume-cache - # volumes: - # - name: modules - # path: /cache - # settings: - # restore: true - # mount: - # - ./node_modules - # - ./yarn.lock - - # - name: build - # image: node:12.16.1 + # - name: prepare-deploy-file + # image: apline # commands: - # - yarn - # - yarn build:prod + # - echo -e "" - # - name: rebuild-modules - # image: drillster/drone-volume-cache - # volumes: - # - name: modules - # path: /cache - # settings: - # rebuild: true - # mount: - # - ./node_modules - # - ./yarn.lock - - # - name: scp - # image: appleboy/drone-scp - # settings: - # host: 124.156.152.247 - # username: - # from_secret: ssh_username - # password: - # from_secret: ssh_pwd - # port: 8011 - # target: - # - /mnt/d/deploy/fe/cidemoadmin - # source: - # - dist - # - docker-compose.yml - # - nginx.conf - # - frpc.ini - - # - name: deploy - # image: appleboy/drone-ssh - # settings: - # host: 124.156.152.247 - # username: - # from_secret: ssh_username - # password: - # from_secret: ssh_pwd - # port: 8011 - # script: - # - cd /mnt/d/deploy/fe/cidemoadmin - # - docker-compose down - # - docker-compose up -d - # - docker-compose logs - -volumes: - - name: modules - host: - path: /mnt/d/ci_volumes + - name: deploy + image: docker/compose + commands: + - docker-compose up -d + - docker-compose logs -f diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..f2d2bffd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM node:lts + +WORKDIR /src + +COPY . . + +RUN yarn global add http-server && \ + npm install pm2 -g && \ + yarn && \ + yarn build:prod + +EXPOSE 80 + +# CMD ["http-server","/src/dist","-p","80"] + +CMD ["bash","http.sh"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 319c3745..655fb732 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,11 +2,8 @@ version: '3' services: - nginx: - image: nginx:1.19.2 - volumes: - - ./dist:/var/www - - ./nginx.conf:/etc/nginx/nginx.conf + web: + image: docker.zcj.plus/drone-ci/fe networks: - feadmindroneci @@ -17,7 +14,7 @@ services: volumes: - ./frpc.ini:/etc/frp/frpc.ini depends_on: - - nginx + - web restart: always networks: diff --git a/http.sh b/http.sh new file mode 100644 index 00000000..65c2d61e --- /dev/null +++ b/http.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +pm2 start http-server -i 4 -- /src/dist -p 80 + +pm2 monit \ No newline at end of file diff --git a/nginx.conf b/nginx.conf index fbf3467a..381021a2 100644 --- a/nginx.conf +++ b/nginx.conf @@ -63,12 +63,16 @@ http { server { listen 80; - server_name demo-admin.ryio.cn; + server_name demo-admin.ryio.cn; location / { - root /var/www; - index index.html; - try_files $uri $uri/ /index.html; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_redirect off; + proxy_set_header REMOTE-HOST $remote_addr; + + proxy_pass http://wev/; } }